This commit is contained in:
kali
2024-03-15 16:56:03 +03:00
parent 6e62ce7363
commit 5bda1e0525
16 changed files with 244 additions and 75 deletions

View File

@ -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;
}
}