Loading includes/webform.theme.template.inc +1 −0 Changes for includes/webform.theme.template.inc: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -720,6 +720,7 @@ function template_preprocess_webform_section(array &$variables) { $variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL; $variables['title_tag'] = isset($element['#title_tag']) ? $element['#title_tag'] : 'h2'; $variables['title_attributes'] = isset($element['#title_attributes']) ? $element['#title_attributes'] : []; $variables['description_display'] = isset($element['#description_display']) ? $element['#description_display'] : 'before'; $variables['children'] = $element['#children']; $variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL; Loading src/Element/WebformSection.php +4 −0 Changes for src/Element/WebformSection.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ class WebformSection extends RenderElement { ], '#value' => NULL, '#title_tag' => 'h2', // Must set default description display to before to prevent it from being // set to after. // @see \Drupal\Core\Form\FormBuilder::doBuildForm '#description_display' => 'before', '#theme_wrappers' => ['webform_section'], ]; } Loading src/Plugin/WebformElement/WebformSection.php +4 −0 Changes for src/Plugin/WebformElement/WebformSection.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class WebformSection extends ContainerBase { 'title_tag' => \Drupal::config('webform.settings')->get('element.default_section_title_tag'), 'title_display' => '', 'title_attributes' => [], 'description_display' => '', 'help_display' => '', ] + parent::defineDefaultProperties(); } Loading Loading @@ -77,6 +78,9 @@ class WebformSection extends ContainerBase { ], ]; // Remove unsupported description display. unset($form['form']['display_container']['description_display']['#options']['tooltip']); return $form; } Loading templates/webform-section.html.twig +10 −1 Changes for templates/webform-section.html.twig: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,6 +13,12 @@ * - description: The description element containing the following properties: * - content: The description content of the <fieldset>. * - attributes: HTML attributes to apply to the description container. * - description_display: Description display setting. It can have these values: * - before: The description is output before the element. * - after: The description is output after the element. This is the default * value. * - invisible: The description is output after the element, hidden visually * but available to screen readers. * - children: The rendered child elements of the <fieldset>. * - prefix: The content to add before the .section-wrapper children. * - suffix: The content to add after the .section-wrapper children. Loading Loading @@ -50,7 +56,7 @@ {{ errors }} </div> {% endif %} {% if description.content %} {% if description_display in ['before', 'invisible'] and description.content %} <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div> {% endif %} {% if prefix %} Loading @@ -60,5 +66,8 @@ {% if suffix %} <span class="field-suffix">{{ suffix }}</span> {% endif %} {% if description_display == 'after' and description.content %} <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div> {% endif %} </div> </section> tests/modules/webform_test/config/install/webform.webform.test_element_section.yml +28 −1 Changes for tests/modules/webform_test/config/install/webform.webform.test_element_section.yml: 28 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -35,7 +35,34 @@ elements: | '#title_tag': h5 '#title_attributes': style: 'color: red' webform_section_description_display_default: '#type': webform_section '#title': webform_section_description_display_default '#description': 'Display default description.' webform_section_description_display_default_textfield: '#type': textfield '#title': webform_section_description_display_default_textfield webform_section_description_display_before: '#type': webform_section '#title': webform_section_description_display_before '#description': 'Display before description.' '#description_display': 'before' webform_section_description_display_before_textfield: '#type': textfield '#title': webform_section_description_display_before_textfield webform_section_description_display_after: '#type': webform_section '#title': webform_section_description_display_after '#description': 'Display after description.' '#description_display': 'after' webform_section_description_display_after_textfield: '#type': textfield '#title': webform_section_description_display_after_textfield webform_section_description_display_invisible: '#type': webform_section '#title': webform_section_description_display_invisible '#description': 'Display invisible description.' '#description_display': 'invisible' css: '' javascript: '' settings: Loading Loading
includes/webform.theme.template.inc +1 −0 Changes for includes/webform.theme.template.inc: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -720,6 +720,7 @@ function template_preprocess_webform_section(array &$variables) { $variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL; $variables['title_tag'] = isset($element['#title_tag']) ? $element['#title_tag'] : 'h2'; $variables['title_attributes'] = isset($element['#title_attributes']) ? $element['#title_attributes'] : []; $variables['description_display'] = isset($element['#description_display']) ? $element['#description_display'] : 'before'; $variables['children'] = $element['#children']; $variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL; Loading
src/Element/WebformSection.php +4 −0 Changes for src/Element/WebformSection.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ class WebformSection extends RenderElement { ], '#value' => NULL, '#title_tag' => 'h2', // Must set default description display to before to prevent it from being // set to after. // @see \Drupal\Core\Form\FormBuilder::doBuildForm '#description_display' => 'before', '#theme_wrappers' => ['webform_section'], ]; } Loading
src/Plugin/WebformElement/WebformSection.php +4 −0 Changes for src/Plugin/WebformElement/WebformSection.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ class WebformSection extends ContainerBase { 'title_tag' => \Drupal::config('webform.settings')->get('element.default_section_title_tag'), 'title_display' => '', 'title_attributes' => [], 'description_display' => '', 'help_display' => '', ] + parent::defineDefaultProperties(); } Loading Loading @@ -77,6 +78,9 @@ class WebformSection extends ContainerBase { ], ]; // Remove unsupported description display. unset($form['form']['display_container']['description_display']['#options']['tooltip']); return $form; } Loading
templates/webform-section.html.twig +10 −1 Changes for templates/webform-section.html.twig: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -13,6 +13,12 @@ * - description: The description element containing the following properties: * - content: The description content of the <fieldset>. * - attributes: HTML attributes to apply to the description container. * - description_display: Description display setting. It can have these values: * - before: The description is output before the element. * - after: The description is output after the element. This is the default * value. * - invisible: The description is output after the element, hidden visually * but available to screen readers. * - children: The rendered child elements of the <fieldset>. * - prefix: The content to add before the .section-wrapper children. * - suffix: The content to add after the .section-wrapper children. Loading Loading @@ -50,7 +56,7 @@ {{ errors }} </div> {% endif %} {% if description.content %} {% if description_display in ['before', 'invisible'] and description.content %} <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div> {% endif %} {% if prefix %} Loading @@ -60,5 +66,8 @@ {% if suffix %} <span class="field-suffix">{{ suffix }}</span> {% endif %} {% if description_display == 'after' and description.content %} <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div> {% endif %} </div> </section>
tests/modules/webform_test/config/install/webform.webform.test_element_section.yml +28 −1 Changes for tests/modules/webform_test/config/install/webform.webform.test_element_section.yml: 28 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -35,7 +35,34 @@ elements: | '#title_tag': h5 '#title_attributes': style: 'color: red' webform_section_description_display_default: '#type': webform_section '#title': webform_section_description_display_default '#description': 'Display default description.' webform_section_description_display_default_textfield: '#type': textfield '#title': webform_section_description_display_default_textfield webform_section_description_display_before: '#type': webform_section '#title': webform_section_description_display_before '#description': 'Display before description.' '#description_display': 'before' webform_section_description_display_before_textfield: '#type': textfield '#title': webform_section_description_display_before_textfield webform_section_description_display_after: '#type': webform_section '#title': webform_section_description_display_after '#description': 'Display after description.' '#description_display': 'after' webform_section_description_display_after_textfield: '#type': textfield '#title': webform_section_description_display_after_textfield webform_section_description_display_invisible: '#type': webform_section '#title': webform_section_description_display_invisible '#description': 'Display invisible description.' '#description_display': 'invisible' css: '' javascript: '' settings: Loading