first
This commit is contained in:
55
src/inputs/Select.php
Normal file
55
src/inputs/Select.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace src\inputs;
|
||||
|
||||
use src\traits\CreateOption;
|
||||
use src\traits\CreateParams;
|
||||
|
||||
class Select
|
||||
{
|
||||
use CreateParams;
|
||||
use CreateOption;
|
||||
private $name;
|
||||
private $options;
|
||||
private $value;
|
||||
private $paramsArray;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $options
|
||||
* @param $value
|
||||
* @param array $paramsArray
|
||||
*/
|
||||
public function __construct(string $name, array $options = [], $value = null, array $paramsArray = [])
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->options = $options;
|
||||
$this->value = $value;
|
||||
$this->paramsArray = $paramsArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function create(): void
|
||||
{
|
||||
$paramsString = $this->createParams($this->paramsArray);
|
||||
$optionsString = $this->createOption($this->options, $this->value);
|
||||
echo "<select name='$this->name' $paramsString>$optionsString</select>";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $options
|
||||
* @param $value
|
||||
* @param array $paramsArray
|
||||
* @return void
|
||||
*/
|
||||
public static function build(string $name, array $options = [], $value = null, array $paramsArray = []): void
|
||||
{
|
||||
$textarea = new self($name, $options, $value, $paramsArray);
|
||||
$textarea->create();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user