diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php index c752cef..384d221 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.php @@ -271,27 +271,33 @@ public function validateOptionsForm(&$form, &$form_state) { } * Build the options form. */ public function buildOptionsForm(&$form, &$form_state) { - // Some form elements belong in a fieldset for presentation, but can't - // be moved into one because of the form_state['values'] hierarchy. Those - // elements can add a #fieldset => 'fieldset_name' property, and they'll - // be moved to their fieldset during pre_render. - $form['#pre_render'][] = 'views_ui_pre_render_add_fieldset_markup'; + parent::buildOptionsForm($form, $form_state); + + $form['fieldsets'] = array( + '#type' => 'value', + '#value' => array('more'), + ); $form['admin_label'] = array( + '#type' => 'details', + '#title' => t('Administrative title'), + '#collapsed' => TRUE, + '#weight' => 150, + ); + $form['admin_label']['admin_label'] = array( '#type' => 'textfield', '#title' => t('Administrative title'), '#description' => t('This title will be displayed on the views edit page instead of the default one. This might be useful if you have the same item twice.'), '#default_value' => $this->options['admin_label'], - '#fieldset' => 'more', ); // This form is long and messy enough that the "Administrative title" option // belongs in "Administrative title" fieldset at the bottom of the form. $form['more'] = array( '#type' => 'details', - '#title' => 'Administrative title', + '#title' => t('More'), '#collapsed' => TRUE, - '#weight' => 150, + '#weight' => 200, ); // Allow to alter the default values brought into the form. // @todo Do we really want to keep this hook. diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index a723854..9a4fcb9 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -275,6 +275,15 @@ function views_ui_pre_render_add_fieldset_markup($form) { } } + // Hide the fieldsets if there is nothing on there. + if (isset($form['#fieldsets'])) { + foreach ($form['fieldsets']['#value'] as $fieldset) { + if (!element_children($form[$fieldset])) { + $form[$fieldset]['#access'] = FALSE; + } + } + } + return $form; }