diff --git a/css/views-admin.theme.css b/css/views-admin.theme.css index 27c021c14ac0a6f6f83ee44ac94802bcfae0b318..b785abd77c230433d732c128a2124b9ef16b98ea 100644 --- a/css/views-admin.theme.css +++ b/css/views-admin.theme.css @@ -464,6 +464,15 @@ ul#views-display-menu-tabs li.add ul.action-list li{ padding: 3px 7px; } +/** + * Display a red border if the display doesn't validate. + */ +.views-displays ul.secondary li.active a.active.error, +.views-displays .secondary a.error { + border: 2px solid #ED541D; + padding: 1px 6px; +} + .views-displays .secondary a:focus { outline: none; } diff --git a/includes/admin.inc b/includes/admin.inc index 52af8a27b4cb3862f229e860a158e87f4e654216..925250ba836b2cacbac636bd5f79983da71bf2c8 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -1472,7 +1472,7 @@ function views_ui_edit_form_submit_delay_destination($form, &$form_state) { * having them as secondary local tasks isn't desired. The caller is responsible * for setting the active tab's #active property to TRUE. * - * @param $view + * @param view $view * The view which will be edited. * @param $display_id * The display_id which is edited on the current request. @@ -1503,6 +1503,18 @@ function views_ui_edit_page_display_tabs($view, $display_id = NULL) { $tabs['default']['#access'] = FALSE; } + // Mark the display tab as red to show validation errors. + $view->validate(); + foreach ($view->display as $id => $display) { + if (!empty($view->display_errors[$id])) { + // Always show the tab. + $tabs[$id]['#access'] = TRUE; + // Add a class to mark the error and a title to make a hover tip. + $tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'error'; + $tabs[$id]['#link']['localized_options']['attributes']['title'] = t('This display has one or more validation errors; please review it.'); + } + } + return $tabs; } diff --git a/lib/Drupal/views/View.php b/lib/Drupal/views/View.php index 8b4598befa3e9edfab6aa1f259b698b9f346ac1d..40c46761536b686aea7c84f4e9b9df456c1f4673 100644 --- a/lib/Drupal/views/View.php +++ b/lib/Drupal/views/View.php @@ -2072,6 +2072,7 @@ function validate() { $this->init_display(); $errors = array(); + $this->display_errors = NULL; $current_display = $this->current_display; foreach ($this->display as $id => $display) { @@ -2083,6 +2084,8 @@ function validate() { $result = $this->display[$id]->handler->validate(); if (!empty($result) && is_array($result)) { $errors = array_merge($errors, $result); + // Mark this display as having validation errors. + $this->display_errors[$id] = TRUE; } } }