diff --git a/core/includes/form.inc b/core/includes/form.inc index 58563c6..00c0ff6 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -193,9 +193,9 @@ function template_preprocess_fieldset(&$variables) { Element::setAttributes($element, array('id')); Element\RenderElement::setAttributes($element); $variables['attributes'] = $element['#attributes']; - $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; - $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; - $variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL; + $variables['prefix'] = $element['#field_prefix']; + $variables['suffix'] = $element['#field_suffix']; + $variables['title_display'] = $element['#title_display']; $variables['children'] = $element['#children']; $variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL; diff --git a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php index bf8d21c..360cb68 100644 --- a/core/modules/system/src/Tests/Form/ElementsLabelsTest.php +++ b/core/modules/system/src/Tests/Form/ElementsLabelsTest.php @@ -128,4 +128,27 @@ function testFormDescriptions() { $this->assertTrue(isset($elements[0]), t('Properly renders the #description element visually-hidden.')); } + /** + * Test forms in theme-less environments. + */ + function testFormsInThemeLessEnvironments() { + $form = $this->getFormWithLimitedProperties(); + $render_service = $this->container->get('renderer'); + // This should not throw any notices. + $render_service->renderPlain($form); + } + + /** + * Return a form with element with not all properties defined. + */ + protected function getFormWithLimitedProperties() { + $form = array(); + + $form['fieldset'] = array( + '#type' => 'fieldset', + '#title' => 'Fieldset', + ); + + return $form; + } }