Fixed 'img' tags, removed utf8_encode since it's deprecated and readded echoRaw from textarea widget

This commit is contained in:
Dave Mc Nicoll 2023-04-13 15:51:29 -04:00
parent ea780c697e
commit fd4e30bd42
3 changed files with 12 additions and 4 deletions

View File

@ -11,8 +11,6 @@ class UiImage extends UiElement implements Extension {
public array $tokens = [ "ui:img", "ui:image" ];
public string $tag = "img";
public array $attributes = [
'class' => 'ui-image',
];
@ -21,6 +19,10 @@ class UiImage extends UiElement implements Extension {
'tag-type' => "single",
];
public function __construct(
public string $tag = "img",
) {}
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string
{
return "<?php echo ( new \\" . static::class . "() )->buildHtml($arguments) ?>";

View File

@ -25,9 +25,15 @@ class UiTextarea extends UiInput {
return "<?php echo ( new \\" . static::class . "(raw: $raw) )->buildHtml($arguments) ?>";
}
protected function setValue($value) : void
{
$this->echoRaw ? $this->html($value) : $this->text($value);
}
protected function echoRaw(bool $value) : self
{
$this->echoRaw = $value;
return $this;
}
}

View File

@ -38,7 +38,7 @@ class FormContext implements FormContextInterface
$this->values = $request->getParsedBody() ?: [];
if ( ! $this->values ) {
$content = utf8_encode((string) $request->getBody());
$content = mb_convert_encoding((string) $request->getBody(), 'UTF-8');
if ( $content && ( $json = json_decode($content, true) ) ) {
$this->values = $json;