update
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace src\inputs;
|
||||
namespace itguild\forms\inputs;
|
||||
|
||||
use src\traits\CreateParams;
|
||||
use itguild\forms\traits\CreateParams;
|
||||
use itguild\forms\inputs\BaseInput;
|
||||
|
||||
class Checkbox
|
||||
class Checkbox extends BaseInput
|
||||
{
|
||||
use CreateParams;
|
||||
|
||||
@ -12,6 +13,7 @@ class Checkbox
|
||||
private string $value;
|
||||
private array $paramsArray;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
@ -25,12 +27,13 @@ class Checkbox
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @return $this
|
||||
*/
|
||||
public function create(): void
|
||||
public function create(): self
|
||||
{
|
||||
$paramsString = $this->createParams($this->paramsArray);
|
||||
echo "<input name='$this->name' type='checkbox' value='$this->value' $paramsString >";
|
||||
$this->html = "<input name='$this->name' type='checkbox' value='$this->value' $paramsString >";
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,8 +45,17 @@ class Checkbox
|
||||
public static function build(string $name, string $value, array $paramsArray): void
|
||||
{
|
||||
$checkbox = new self($name, $value, $paramsArray);
|
||||
$checkbox->create();
|
||||
$checkbox->create()->render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @return $this
|
||||
*/
|
||||
public function setLabel(string $title): self
|
||||
{
|
||||
$this->html = "<label>$title $this->html</label>";
|
||||
return $this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user