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.
13 class EditDetails extends ViewsFormBase {
18 public function getFormKey() {
19 return 'edit-details';
25 public function getFormId() {
26 return 'views_ui_edit_details_form';
32 public function buildForm(array $form, FormStateInterface $form_state) {
33 $view = $form_state->get('view');
35 $form['#title'] = $this->t('Name and description');
36 $form['#section'] = 'details';
39 '#theme_wrappers' => ['container'],
40 '#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
42 $form['details']['label'] = [
43 '#type' => 'textfield',
44 '#title' => t('Administrative name'),
45 '#default_value' => $view->label(),
47 $form['details']['langcode'] = [
48 '#type' => 'language_select',
49 '#title' => $this->t('View language'),
50 '#description' => $this->t('Language of labels and other textual elements in this view.'),
51 '#default_value' => $view->get('langcode'),
53 $form['details']['description'] = [
54 '#type' => 'textfield',
55 '#title' => t('Administrative description'),
56 '#default_value' => $view->get('description'),
58 $form['details']['tag'] = [
59 '#type' => 'textfield',
60 '#title' => t('Administrative tags'),
61 '#description' => t('Enter a comma-separated list of words to describe your view.'),
62 '#default_value' => $view->get('tag'),
63 '#autocomplete_route_name' => 'views_ui.autocomplete',
66 $view->getStandardButtons($form, $form_state, 'views_ui_edit_details_form');
73 public function submitForm(array &$form, FormStateInterface $form_state) {
74 $view = $form_state->get('view');
75 foreach ($form_state->getValues() as $key => $value) {
76 // Only save values onto the view if they're actual view properties
77 // (as opposed to 'op' or 'form_build_id').
78 if (isset($form['details'][$key])) {
79 $view->set($key, $value);
82 $bases = Views::viewsData()->fetchBaseTables();
83 $page_title = $view->label();
84 if (isset($bases[$view->get('base_table')])) {
85 $page_title .= ' (' . $bases[$view->get('base_table')]['title'] . ')';
87 $form_state->set('page_title', $page_title);