Commit 80504881 authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1345934 by dawehner, damiankloip, joachim: Fixed default display being...

Issue #1345934 by dawehner, damiankloip, joachim: Fixed default display being hidden makes it possible to be unable to save a view with validation errors.
parent e5079a42
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment