From ef3b41fa90d7f813fd22b31851fc515da1d19e62 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 7 Mar 2023 10:54:36 +0100 Subject: [PATCH 1/3] Fixed template horizontal form theme for ckeditor comments fields with fullWidth parameter Notes: The 'fullwidth' parameter allow to force enlarge textarea ckeditor field, escaping horizontal bootstrap theme position rule (4/12 - 8/12) --- .../ChillMainBundle/Form/Type/CommentType.php | 7 +- .../Form/Type/ScopePickerType.php | 7 +- .../Resources/views/Form/fields.html.twig | 64 +++++++++---------- 3 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Form/Type/CommentType.php b/src/Bundle/ChillMainBundle/Form/Type/CommentType.php index 9b8fc4701..542a429c6 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/CommentType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/CommentType.php @@ -56,12 +56,7 @@ class CommentType extends AbstractType public function buildView(FormView $view, FormInterface $form, array $options) { - $view->vars = array_replace( - $view->vars, - [ - 'fullWidth' => true, - ] - ); + $view->vars['fullWidth'] = true; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php index f65677dc7..79ed6df40 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php @@ -95,12 +95,7 @@ class ScopePickerType extends AbstractType public function buildView(FormView $view, FormInterface $form, array $options) { - $view->vars = array_replace( - $view->vars, - [ - 'fullWidth' => true, - ] - ); + $view->vars['fullWidth'] = true; } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 15d7625dd..83958b22e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -18,41 +18,42 @@ {% block form_row %} {% apply spaceless %} - {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %}
-
+ {% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %} + {{ form_label(form) }} {% endif %} - {% endapply %}"> - {% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %} - {{ form_label(form) }} +
+
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+ {% else %} +
{{ form_label(form) }}
+
{{ form_widget(form) }}
{% endif %} -
-
- {{ form_widget(form) }} - {{ form_errors(form) }} -
- {% else %} - {{ form_widget(form) }} - {% endif %} {% endapply %} {% endblock form_row %} @@ -210,11 +211,6 @@ {% endfor %} {% endblock %} -{% block comment_row %} - {{ form_label(form) }} - {{ form_row(form) }} -{% endblock %} - {% block comment_widget %} {% for entry in form %} {{ form_widget(entry) }} From 9d1703ccba9d33ce2984c5815871e542d2dffa40 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 7 Mar 2023 15:58:18 +0100 Subject: [PATCH 2/3] remove comment --- .../ChillMainBundle/Resources/views/Form/fields.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 83958b22e..5a577fecd 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -20,7 +20,7 @@ {% apply spaceless %}
- {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %} {# here #} + {% if form.vars.fullWidth is not defined or form.vars.fullWidth == false %}
+
{{- form_label(form) -}}
+
{{- form_widget(form, widget_attr) -}} {{- form_help(form) -}} {{- form_errors(form) -}} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 5a577fecd..dfa851eed 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -56,6 +56,10 @@
{% endapply %} {% endblock form_row %} +{# + The block 'form_row' above may be removed ! + Read this note: https://gitlab.com/Chill-Projet/chill-bundles/-/merge_requests/502#note_1311993084 +#} {% block choice_widget_expanded %} {% apply spaceless %} @@ -201,7 +205,6 @@ {% block private_comment_row %} - {{ form_label(form) }} {{ form_row(form) }} {% endblock %} @@ -211,6 +214,10 @@ {% endfor %} {% endblock %} +{% block comment_row %} + {{ form_row(form) }} +{% endblock %} + {% block comment_widget %} {% for entry in form %} {{ form_widget(entry) }}