From 550a9c2760082f8c9e5b559ee64776caa0637034 Mon Sep 17 00:00:00 2001 From: sophie-mulard Date: Thu, 7 Mar 2024 10:56:21 +0100 Subject: [PATCH] Add HTML field type --- FieldType/Html.php | 32 +++++++++++++++++++ Resources/config/field_types.xml | 3 ++ .../translations/AdvancedContentBundle.en.yml | 2 ++ .../translations/AdvancedContentBundle.fr.yml | 2 ++ Resources/views/Field/front/html.html.twig | 11 +++++++ Resources/views/Field/preview/html.html.twig | 11 +++++++ 6 files changed, 61 insertions(+) create mode 100644 FieldType/Html.php create mode 100644 Resources/views/Field/front/html.html.twig create mode 100644 Resources/views/Field/preview/html.html.twig diff --git a/FieldType/Html.php b/FieldType/Html.php new file mode 100644 index 00000000..2ad9c664 --- /dev/null +++ b/FieldType/Html.php @@ -0,0 +1,32 @@ + + + + diff --git a/Resources/translations/AdvancedContentBundle.en.yml b/Resources/translations/AdvancedContentBundle.en.yml index fc2ac595..dddc6bd2 100644 --- a/Resources/translations/AdvancedContentBundle.en.yml +++ b/Resources/translations/AdvancedContentBundle.en.yml @@ -72,6 +72,8 @@ field_type: image_label: Slide %nb% arrow_previous: Previous arrow_next: Next + html: + label: HTML group: other: Others simple: Simple diff --git a/Resources/translations/AdvancedContentBundle.fr.yml b/Resources/translations/AdvancedContentBundle.fr.yml index 03d9b297..dea05f34 100644 --- a/Resources/translations/AdvancedContentBundle.fr.yml +++ b/Resources/translations/AdvancedContentBundle.fr.yml @@ -72,6 +72,8 @@ field_type: image_label: Image %nb% arrow_previous: Précédent arrow_next: Suivant + html: + label: HTML group: other: Autres simple: Simple diff --git a/Resources/views/Field/front/html.html.twig b/Resources/views/Field/front/html.html.twig new file mode 100644 index 00000000..3d0dbab0 --- /dev/null +++ b/Resources/views/Field/front/html.html.twig @@ -0,0 +1,11 @@ +{% if value is not empty %} + {% set attributes = acb_get_element_attributes(extra|default([])) %} + {% set style = attributes.style|default('') %} + +
+ {{ value | raw }} +
+{% endif %} diff --git a/Resources/views/Field/preview/html.html.twig b/Resources/views/Field/preview/html.html.twig new file mode 100644 index 00000000..c0bd4bbb --- /dev/null +++ b/Resources/views/Field/preview/html.html.twig @@ -0,0 +1,11 @@ +{% if value is not empty %} + {% set attributes = acb_get_element_attributes(extra|default([])) %} + {% set style = attributes.style|default('') %} + +
+ {{ value | raw }} +
+{% endif %}