fix label setLabel

This commit is contained in:
kali
2024-03-18 13:25:38 +03:00
parent 1d20c0863b
commit a73c5e8170
8 changed files with 53 additions and 18 deletions

View File

@ -12,6 +12,8 @@ class Checkbox extends BaseInput
private string $name;
private string $value;
private array $paramsArray;
private bool $hasLabel = false;
private string $labelTitle = '';
/**
@ -33,6 +35,10 @@ class Checkbox extends BaseInput
{
$paramsString = $this->createParams($this->paramsArray);
$this->html = "<input name='$this->name' type='checkbox' value='$this->value' $paramsString >";
if($this->hasLabel == true) {
$this->html = "<label>$this->labelTitle</label> $this->html";
}
return $this;
}
@ -55,7 +61,9 @@ class Checkbox extends BaseInput
*/
public function setLabel(string $title): self
{
$this->html = "<label>$title $this->html</label>";
$this->hasLabel = true;
$this->labelTitle = $title;
return $this;
}
}