public static function PluginBase::preRenderAddFieldsetMarkup in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::preRenderAddFieldsetMarkup()
- 10 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::preRenderAddFieldsetMarkup()
Moves form elements into fieldsets for presentation purposes.
Many views forms use #tree = TRUE to keep their values in a hierarchy for easier storage. Moving the form elements into fieldsets during form building would break up that hierarchy. Therefore, we wait until the pre_render stage, where any changes we make affect presentation only and aren't reflected in $form_state->getValues().
Parameters
array $form: The form build array to alter.
Return value
array The form build array.
Overrides ViewsPluginInterface::preRenderAddFieldsetMarkup
File
- core/
modules/ views/ src/ Plugin/ views/ PluginBase.php, line 484
Class
- PluginBase
- Base class for any views plugin types.
Namespace
Drupal\views\Plugin\viewsCode
public static function preRenderAddFieldsetMarkup(array $form) {
foreach (Element::children($form) as $key) {
$element = $form[$key];
// In our form builder functions, we added an arbitrary #fieldset property
// to any element that belongs in a fieldset. If this form element has
// that property, move it into its fieldset.
if (isset($element['#fieldset']) && isset($form[$element['#fieldset']])) {
$form[$element['#fieldset']][$key] = $element;
// Remove the original element this duplicates.
unset($form[$key]);
}
}
return $form;
}