13 March 2024

This code snippet utilizes hook_form_alter to ensure that the 'Default' display tab remains visible in the Views UI edit form of Drupal 7, allowing users to easily access and modify default display settings even when additional displays are present.

Source code viewer
  1. /**
  2.  * Implements hook_form_FORM_ID_alter().
  3.  */
  4. function HOOK_form_views_ui_edit_form_alter(&$form, &$form_state, $form_id) {
  5. // Ensure the "Default" display is always shown.
  6. if (isset($form['displays']['top']['tabs']['default'])) {
  7. // Set the default display as visible.
  8. $form['displays']['top']['tabs']['default']['#access'] = TRUE;
  9. }
  10. }
Programming Language: PHP