60 lines
1.4 KiB
PHP
Executable File
60 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace itguild\forms\form\inputs;
|
|
|
|
use itguild\forms\form\templates\Simple\SimpleTemplate;
|
|
use itguild\forms\form\traits\CreateParams;
|
|
|
|
class TextArea extends BaseInput
|
|
{
|
|
use CreateParams;
|
|
|
|
private $name;
|
|
private $value;
|
|
private $paramsArray;
|
|
|
|
|
|
/**
|
|
* @param string $name
|
|
* @param string $value
|
|
* @param array $paramsArray
|
|
*/
|
|
public function __construct(string $name, string $value = '', array $paramsArray = [])
|
|
{
|
|
$this->name = $name;
|
|
$this->value = $value;
|
|
$this->paramsArray = $paramsArray;
|
|
$this->inputTemplate = new SimpleTemplate();
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function create(): self
|
|
{
|
|
$paramsString = $this->createParams($this->paramsArray);
|
|
$label = "";
|
|
$textarea = "<textarea name='$this->name' $paramsString>$this->value</textarea>";
|
|
|
|
$this->createLabel();
|
|
|
|
$this->html = str_replace('{input}', $textarea, $this->inputTemplate->getInputTemplate());
|
|
$this->html = str_replace('{label}', $this->labelString, $this->html);
|
|
|
|
return $this;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param string $name
|
|
* @param string $value
|
|
* @param array $paramsArray
|
|
* @return void
|
|
*/
|
|
public static function build(string $name, string $value, array $paramsArray = []): void
|
|
{
|
|
$textarea = new self($name, $value, $paramsArray);
|
|
$textarea->create()->render();
|
|
}
|
|
|
|
} |