Skip to content

Commit

Permalink
Ensure double encoding does not happen
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed Dec 4, 2024
1 parent 9e3828a commit faf1520
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Layout/AbstractFormLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function array_key_exists;
use function gettype;
use function in_array;
use function is_string;

abstract class AbstractFormLayout implements FormLayout
{
Expand Down Expand Up @@ -223,14 +224,16 @@ private function addConfiguredAttributes(Widget $widget, Attributes $attributes)
}

foreach ($this->widgetConfig[$type]['attributes'] as $attribute => $key) {
switch (gettype($key)) {
case 'array':
$attributes->setAttribute($attribute, $this->parseArrayAttributeConfig($widget, $key));
break;
$value = match(gettype($key)) {
'array' => $this->parseArrayAttributeConfig($widget, $key),
default => $widget->$key,
};

default:
$attributes->setAttribute($attribute, $widget->$key);
if (is_string($value)) {
$value = StringUtil::decodeEntities($value);
}

$attributes->setAttribute($attribute, $value);
}
}

Expand All @@ -250,6 +253,10 @@ private function parseWidgetAttributes(Widget $widget, Attributes $attributes):
if (in_array($name, static::$booleanAttributes)) {
$attributes->setAttribute($name, true);
} elseif ($value !== '') {
if (is_string($value)) {
$value = StringUtil::decodeEntities($value);
}

$attributes->setAttribute($name, $value);
}
}
Expand Down

0 comments on commit faf1520

Please sign in to comment.