You are here

function views_ui_plugin_validate_list in Views (for Drupal 7) 5

Validate a view with a type: list.

1 call to views_ui_plugin_validate_list()
views_ui_plugin_validate_table in ./views_ui.module
Validate a view with type: table.
1 string reference to 'views_ui_plugin_validate_list'
views_views_style_plugins in ./views.module
Default Views style plugins. Implementation of hook_views_style_plugins()

File

./views_ui.module, line 1875

Code

function views_ui_plugin_validate_list($type, $view, $form) {

  // list (and table) modes require there to be at least 1 field active.
  if (is_array($view['field'])) {
    $fields = array_filter(array_keys($view['field']), 'is_numeric');
  }
  if (!$fields) {
    form_error($form["{$type}-info"][$type . '_type'], t('List and Table types require at least one field.'));
  }
  if (isset($view['field']['count'])) {
    $defaultsort = false;
    for ($i = 0; $i < $view['field']['count']; $i++) {
      if ($view['field'][$i]['defaultsort']) {
        if ($defaultsort) {
          form_error($form['field'][$i]['defaultsort'], t('You can only set on Default Sort on one field.'));
          break;
        }
        $defaultsort = true;
      }
    }
  }
}