You are here

function views_ui_add_form in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 6.2 includes/admin.inc \views_ui_add_form()
  2. 7.3 includes/admin.inc \views_ui_add_form()

Form constructor callback to create the views Add Form, phase 1.

2 string references to 'views_ui_add_form'
views_ui_add_page in includes/admin.inc
Page callback to add a new view.
views_ui_clone_page in includes/admin.inc
Page callback to add a new view.

File

includes/admin.inc, line 586
admin.inc Provides the Views' administrative interface.

Code

function views_ui_add_form(&$form_state) {
  $view = $form_state['view'];
  $form = array();
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('View name'),
    '#description' => t('This is the unique name of the view. It must contain only alphanumeric characters and underscores; it is used to identify the view internally and to generate unique theming template names for this view. If overriding a module provided view, the name must not be changed or instead a new view will be created.'),
    '#required' => TRUE,
    '#maxlength' => 32,
    '#default_value' => $view ? $view->name : '',
    '#attributes' => array(
      'dir' => 'ltr',
    ),
  );
  $form['human_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Human readable name'),
    '#description' => t('You can use a more descriptive name for this view here. Spaces are allowed'),
    '#default_value' => $view ? $view->human_name : '',
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => t('View description'),
    '#description' => t('This description will appear on the Views administrative UI to tell you what the view is about.'),
    '#default_value' => $view ? $view->description : '',
    '#maxlength' => 255,
  );
  $form['tag'] = array(
    '#type' => 'textfield',
    '#title' => t('View tag'),
    '#description' => t('Enter an optional tag for this view; it is used only to help sort views on the administrative page.'),
    '#default_value' => $view ? $view->tag : '',
    '#autocomplete_path' => 'admin/views/ajax/autocomplete/tag',
  );
  $base_tables = array();
  foreach (views_fetch_base_tables() as $table => $info) {
    $base_tables[$table] = $info['title'] . '<div class="description">' . $info['description'] . '</div>';
  }
  $form['base_table'] = array(
    '#type' => 'radios',
    '#title' => t('View type'),
    '#description' => t('The view type is the primary table for which information is being retrieved. The view type controls what arguments, fields, sort criteria and filters are available, so once this is set it <strong>cannot be changed</strong>.'),
    '#default_value' => $view ? $view->base_table : 'node',
    '#options' => $base_tables,
  );
  if ($view) {
    $form['base_table']['#disabled'] = TRUE;
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
    '#validate' => array(
      'views_ui_add_form_validate',
    ),
    '#submit' => array(
      'views_ui_add_form_submit',
    ),
  );
  return $form;
}