*/
protected array $attributes = [
'id' => '',
'name' => '',
'value' => '',
'class' => '',
];
protected string $label = '';
protected string $hint = '';
protected bool $checked = false;
public function setChecked(string $value): void
{
$this->checked = $value !== '';
}
public function render(): string
{
unset($this->attributes['checked']);
$wrapperClass = $this->attributes['class'];
unset($this->attributes['class']);
$this->attributes['class'] = 'form-switch';
helper('form');
$checkbox = form_checkbox($this->attributes, $this->attributes['value'], $this->checked);
$hint = $this->hint === '' ? '' : hint_tooltip($this->hint, 'ml-1');
return <<
{$checkbox}
{$this->slot}{$hint}
HTML;
}
}