fix label setLabel
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user