Overrides Drupal\Core\Entity\EntityFormController::form().
Overrides EntityFormController::form
public function form(array $form, array &$form_state, EntityInterface $view) {
$display_id = $view->displayID;
// Do not allow the form to be cached, because $form_state['view'] can become
// stale between page requests.
// See views_ui_ajax_get_form() for how this affects #ajax.
// @todo To remove this and allow the form to be cacheable:
// - Change $form_state['view'] to $form_state['temporary']['view'].
// - Add a #process function to initialize $form_state['temporary']['view']
// on cached form submissions.
// - Use form_load_include().
$form_state['no_cache'] = TRUE;
if ($display_id) {
if (!$view
->get('executable')
->setDisplay($display_id)) {
$form['#markup'] = t('Invalid display id @display', array(
'@display' => $display_id,
));
return $form;
}
}
$form['#tree'] = TRUE;
$form['#attached']['library'][] = array(
'system',
'jquery.ui.tabs',
);
$form['#attached']['library'][] = array(
'system',
'jquery.ui.dialog',
);
$form['#attached']['library'][] = array(
'system',
'drupal.states',
);
$form['#attached']['library'][] = array(
'system',
'drupal.tabledrag',
);
if (!config('views.settings')
->get('no_javascript')) {
$form['#attached']['library'][] = array(
'views_ui',
'views_ui.admin',
);
}
$form['#attached']['css'] = static::getAdminCSS();
$form['#attached']['js'][] = array(
'data' => array(
'views' => array(
'ajax' => array(
'id' => '#views-ajax-body',
'title' => '#views-ajax-title',
'popup' => '#views-ajax-popup',
'defaultForm' => $view
->getDefaultAJAXMessage(),
),
),
),
'type' => 'setting',
);
$form += array(
'#prefix' => '',
'#suffix' => '',
);
$form['#prefix'] .= '<div class="views-edit-view views-admin clearfix">';
$form['#suffix'] = '</div>' . $form['#suffix'];
$form['#attributes']['class'] = array(
'form-edit',
);
if (isset($view->locked) && is_object($view->locked) && $view->locked->owner != $GLOBALS['user']->uid) {
$form['locked'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'view-locked',
'messages',
'warning',
),
),
'#children' => t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="!break">break this lock</a>.', array(
'!user' => theme('username', array(
'account' => user_load($view->locked->owner),
)),
'!age' => format_interval(REQUEST_TIME - $view->locked->updated),
'!break' => url('admin/structure/views/view/' . $view
->get('name') . '/break-lock'),
)),
'#weight' => -10,
);
}
else {
if (isset($view->vid) && $view->vid == 'new') {
$message = t('* All changes are stored temporarily. Click Save to make your changes permanent. Click Cancel to discard the view.');
}
else {
$message = t('* All changes are stored temporarily. Click Save to make your changes permanent. Click Cancel to discard your changes.');
}
$form['changed'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'view-changed',
'messages',
'warning',
),
),
'#children' => $message,
'#weight' => -10,
);
if (empty($view->changed)) {
$form['changed']['#attributes']['class'][] = 'js-hide';
}
}
$form['help_text'] = array(
'#type' => 'container',
'#children' => t('Modify the display(s) of your view below or add new displays.'),
);
$form['displays'] = array(
'#prefix' => '<h1 class="unit-title clearfix">' . t('Displays') . '</h1>',
'#type' => 'container',
'#attributes' => array(
'class' => array(
'views-displays',
),
),
);
$form['displays']['top'] = $this
->renderDisplayTop($view);
// The rest requires a display to be selected.
if ($display_id) {
$form_state['display_id'] = $display_id;
// The part of the page where editing will take place.
$form['displays']['settings'] = array(
'#type' => 'container',
'#id' => 'edit-display-settings',
);
$display_title = $this
->getDisplayLabel($view, $display_id, FALSE);
// Add a text that the display is disabled.
if (!empty($view
->get('executable')->displayHandlers[$display_id])) {
if (!$view
->get('executable')->displayHandlers[$display_id]
->isEnabled()) {
$form['displays']['settings']['disabled']['#markup'] = t('This display is disabled.');
}
}
// Add the edit display content
$tab_content = $this
->getDisplayTab($view);
$tab_content['#theme_wrappers'] = array(
'container',
);
$tab_content['#attributes'] = array(
'class' => array(
'views-display-tab',
),
);
$tab_content['#id'] = 'views-tab-' . $display_id;
// Mark deleted displays as such.
$display = $view
->get('display');
if (!empty($display[$display_id]['deleted'])) {
$tab_content['#attributes']['class'][] = 'views-display-deleted';
}
// Mark disabled displays as such.
if (isset($view
->get('executable')->displayHandlers[$display_id]) && !$view
->get('executable')->displayHandlers[$display_id]
->isEnabled()) {
$tab_content['#attributes']['class'][] = 'views-display-disabled';
}
$form['displays']['settings']['settings_content'] = array(
'#type' => 'container',
'tab_content' => $tab_content,
);
// The content of the popup dialog.
$form['ajax-area'] = array(
'#type' => 'container',
'#id' => 'views-ajax-popup',
);
$form['ajax-area']['ajax-title'] = array(
'#markup' => '<h2 id="views-ajax-title"></h2>',
);
$form['ajax-area']['ajax-body'] = array(
'#type' => 'container',
'#id' => 'views-ajax-body',
'#children' => $view
->getDefaultAJAXMessage(),
);
}
return $form;
}