3 namespace Drupal\views_ui\Form\Ajax;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Views;
9 * Provides a form for editing the details of a View.
11 class EditDetails extends ViewsFormBase {
16 public function getFormKey() {
17 return 'edit-details';
23 public function getFormId() {
24 return 'views_ui_edit_details_form';
30 public function buildForm(array $form, FormStateInterface $form_state) {
31 $view = $form_state->get('view');
33 $form['#title'] = $this->t('Name and description');
34 $form['#section'] = 'details';
37 '#theme_wrappers' => ['container'],
38 '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
40 $form['details']['label'] = [
41 '#type' => 'textfield',
42 '#title' => t('Administrative name'),
43 '#default_value' => $view->label(),
45 $form['details']['langcode'] = [
46 '#type' => 'language_select',
47 '#title' => $this->t('View language'),
48 '#description' => $this->t('Language of labels and other textual elements in this view.'),
49 '#default_value' => $view->get('langcode'),
51 $form['details']['description'] = [
52 '#type' => 'textfield',
53 '#title' => t('Administrative description'),
54 '#default_value' => $view->get('description'),
56 $form['details']['tag'] = [
57 '#type' => 'textfield',
58 '#title' => t('Administrative tags'),
59 '#description' => t('Enter a comma-separated list of words to describe your view.'),
60 '#default_value' => $view->get('tag'),
61 '#autocomplete_route_name' => 'views_ui.autocomplete',
64 $view->getStandardButtons($form, $form_state, 'views_ui_edit_details_form');
71 public function submitForm(array &$form, FormStateInterface $form_state) {
72 $view = $form_state->get('view');
73 foreach ($form_state->getValues() as $key => $value) {
74 // Only save values onto the view if they're actual view properties
75 // (as opposed to 'op' or 'form_build_id').
76 if (isset($form['details'][$key])) {
77 $view->set($key, $value);
80 $bases = Views::viewsData()->fetchBaseTables();
81 $page_title = $view->label();
82 if (isset($bases[$view->get('base_table')])) {
83 $page_title .= ' (' . $bases[$view->get('base_table')]['title'] . ')';
85 $form_state->set('page_title', $page_title);