update 3
This commit is contained in:
37
src/inputs/CgSelectInput.php
Normal file
37
src/inputs/CgSelectInput.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\inputs;
|
||||
use itguild\forms\inputs\BaseInput;
|
||||
class CgSelectInput extends BaseInput
|
||||
{
|
||||
|
||||
private string $selector;
|
||||
private array $params;
|
||||
private $params;
|
||||
public function __construct(string $selector, array $params = [])
|
||||
{
|
||||
$this->selector = $selector;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$paramsString = $this->createParams($this->paramsArray);
|
||||
$optionsString = $this->createOption($this->options, $this->value);
|
||||
$label = "";
|
||||
$select = "<select name='$this->name' $paramsString>$optionsString</select>";
|
||||
if($this->hasLabel == true) {
|
||||
$label = "<label>$this->labelTitle</label>";
|
||||
}
|
||||
$this->html = str_replace('{input}', $select, $this->inputTemplate->getInputTemplate());
|
||||
$this->html = str_replace('{label}', $label, $this->html);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function build(string $name, array $options = [], $value = null, array $paramsArray = []): void
|
||||
{
|
||||
$select = new self($name, $options, $value, $paramsArray);
|
||||
$select->create()->render();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user