value = true; return $this; } public function setValue(mixed $value): static { if (!is_bool($value) && !is_null($value)) $value = true; return parent::setValue($value); } /** * Require this field for validation. * * If an errorMessage is provided, it shall be displayed instead of the standard 'checkbox is required'. * * @param string|null $errorMessage * @return $this */ public function required(string $errorMessage = null): static { $this->optional = false; if (!is_null($errorMessage)) $this->emptyErrorString = $errorMessage; return $this; } /** * @inheritDoc */ protected function validateField(): bool { return true; } /** * @inheritDoc */ public function generateHtml(): string { $id = "id='".$this->getId()."'"; $name = "name='".$this->getName()."'"; $class = "class='".implode(" ", $this->classNames)."'"; $value = $this->value ? "checked" : ""; $lock = $this->lock ? "disabled" : ""; return ""; } }