diff --git a/src/Config/Crud.php b/src/Config/Crud.php index 1f57d42388..99f6d3945c 100644 --- a/src/Config/Crud.php +++ b/src/Config/Crud.php @@ -430,4 +430,23 @@ private function getValidPageNames(): array { return [self::PAGE_DETAIL, self::PAGE_EDIT, self::PAGE_INDEX, self::PAGE_NEW]; } + + public function getHtmlAttributes(): array + { + return $this->dto->getHtmlAttributes(); + } + + public function setHtmlAttributes(array $htmlAttributes): self + { + $this->dto->setHtmlAttributes($htmlAttributes); + + return $this; + } + + public function setHtmlAttribute(string $attribute, mixed $value): self + { + $this->dto->setHtmlAttribute($attribute, $value); + + return $this; + } } diff --git a/src/Dto/CrudDto.php b/src/Dto/CrudDto.php index 82a2e46bb9..e407bb6d98 100644 --- a/src/Dto/CrudDto.php +++ b/src/Dto/CrudDto.php @@ -65,6 +65,7 @@ final class CrudDto private ?string $contentWidth = null; private ?string $sidebarWidth = null; private bool $hideNullValues = false; + private array $htmlAttributes = []; public function __construct() { @@ -507,4 +508,19 @@ public function hideNullValues(bool $hide): void { $this->hideNullValues = $hide; } + + public function getHtmlAttributes(): array + { + return $this->htmlAttributes; + } + + public function setHtmlAttributes(array $htmlAttributes): void + { + $this->htmlAttributes = $htmlAttributes; + } + + public function setHtmlAttribute(string $attribute, mixed $value): void + { + $this->htmlAttributes[$attribute] = $value; + } } diff --git a/src/Resources/views/layout.html.twig b/src/Resources/views/layout.html.twig index a13fb14e39..06eec72689 100644 --- a/src/Resources/views/layout.html.twig +++ b/src/Resources/views/layout.html.twig @@ -52,6 +52,12 @@ {% endblock %} +{% macro render_html_attributes(attributes) %} + {% for attribute_name, attribute_value in attributes %} + {{ attribute_name }}="{{ attribute_value|e('html_attr') }}" + {% endfor %} +{% endmacro %} + {% block body %}
+