41 lines
923 B
PHP
41 lines
923 B
PHP
<?php
|
|
|
|
namespace Picea\Ui\Form;
|
|
|
|
class UiTextarea extends UiInput {
|
|
|
|
public array $tokens = [ "ui.textarea", "ui.textarea.raw" ];
|
|
|
|
public string $tag = "textarea";
|
|
|
|
public array $attributes = [
|
|
'class' => "ui-textarea",
|
|
];
|
|
|
|
public array $options = [];
|
|
|
|
protected bool $echoRaw = false;
|
|
|
|
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) : string
|
|
{
|
|
if ($token === 'ui.textarea.raw') {
|
|
$this->echoRaw = true;
|
|
}
|
|
|
|
return sprintf("<?php echo ( new \\" . static::class . "() )->echoRaw(%s)->buildHtml($arguments) ?>", $this->echoRaw ? 'true' : 'false');
|
|
}
|
|
|
|
|
|
protected function setValue($value) : void
|
|
{
|
|
$this->echoRaw ? $this->html($value) : $this->text($value);
|
|
}
|
|
|
|
public function echoRaw(bool $set) : self
|
|
{
|
|
$this->echoRaw = $set;
|
|
|
|
return $this;
|
|
}
|
|
}
|