getStandardButtons example

$types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure extra settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $form['#section'] = $display_id . '-' . $type . '-' . $id;

        // Get form from the handler.         $handler->buildExtraOptionsForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_extra_form');
    }
    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $form_state->get('handler')->validateExtraOptionsForm($form['options']$form_state);
  }

  

      $form['filters'][$id]['removed'] = [
        '#title' => $this->t('Remove @id', ['@id' => $id]),
        '#title_display' => 'invisible',
        '#type' => 'checkbox',
        '#id' => 'views-removed-' . $id,
        '#attributes' => ['class' => ['views-remove-checkbox']],
        '#default_value' => 0,
      ];
    }

    $view->getStandardButtons($form$form_state, 'views_ui_rearrange_filter_form');
    $form['actions']['add_group'] = [
      '#type' => 'submit',
      '#value' => $this->t('Create new filter group'),
      '#id' => 'views-add-group',
      '#group' => 'add',
      '#attributes' => [
        'class' => ['views-add-group'],
      ],
      '#ajax' => ['url' => NULL],
    ];

    

    // Add a div to show the selected items     $form['selected'] = [
      '#type' => 'item',
      '#markup' => '<span class="views-ui-view-title">' . $this->t('Selected:') . '</span> ' . '<div class="views-selected-options"></div>',
      '#theme_wrappers' => ['form_element', 'views_ui_container'],
      '#attributes' => [
        'class' => ['container-inline', 'views-add-form-selected', 'views-offset-bottom'],
        'data-drupal-views-offset' => 'bottom',
      ],
    ];
    $view->getStandardButtons($form$form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', ['@types' => $ltitle]));

    // Remove the default submit function.     $form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit']function D$var) {
      return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
    });
    $form['actions']['submit']['#submit'][] = [$view, 'submitItemAdd'];

    return $form;
  }

}
    // $form instead of just the ['options'] section.     $form['#title'] = $form['options']['#title'];
    unset($form['options']['#title']);

    // Move the override dropdown out of the scrollable section of the form.     if (isset($form['options']['override'])) {
      $form['override'] = $form['options']['override'];
      unset($form['options']['override']);
    }

    $name = $form_state->get('update_name');
    $view->getStandardButtons($form$form_state, 'views_ui_edit_display_form', $name);
    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $view->getExecutable()->displayHandlers->get($display_id)->validateOptionsForm($form['options']$form_state);

    

      else {
        $handler->init($executable$executable->display_handler, $item);
        $types = ViewExecutable::getHandlerTypes();

        $form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);

        $handler->buildGroupByForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_group_form');
    }
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $item = &$form_state->get('handler')->options;
    $type = $form_state->get('type');

    
'#title' => $this->t('Administrative description'),
      '#default_value' => $view->get('description'),
    ];
    $form['details']['tag'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Administrative tags'),
      '#description' => $this->t('Enter a comma-separated list of words to describe your view.'),
      '#default_value' => $view->get('tag'),
      '#autocomplete_route_name' => 'views_ui.autocomplete',
    ];

    $view->getStandardButtons($form$form_state, 'views_ui_edit_details_form');
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    foreach ($form_state->getValues() as $key => $value) {
      // Only save values onto the view if they're actual view properties       // (as opposed to 'op' or 'form_build_id').


        $form['#section'] = $display_id . '-' . $type . '-' . $id;

        // Get form from the handler.         $handler->buildOptionsForm($form['options']$form_state);
        $form_state->set('handler', $handler);
      }

      $name = $form_state->get('update_name');

      $view->getStandardButtons($form$form_state, 'views_ui_config_item_form', $name);
      // Add a 'remove' button.       $form['actions']['remove'] = [
        '#type' => 'submit',
        '#value' => $this->t('Remove'),
        '#submit' => [[$this, 'remove']],
        '#limit_validation_errors' => [['override']],
        '#button_type' => 'danger',
      ];
    }

    if ($save_ui_cache) {
      
'attributes' => [
              'id' => 'views-remove-link-' . $id,
              'class' => ['views-hidden', 'views-button-remove', 'views-remove-link'],
              'alt' => $this->t('Remove this item'),
              'title' => $this->t('Remove this item'),
            ],
          ])
        )->toString(),
      ];
    }

    $view->getStandardButtons($form$form_state, 'views_ui_rearrange_form');

    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');

    
$analyzer = Views::analyzer();
    $messages = $analyzer->getMessages($view->getExecutable());

    $form['analysis'] = [
      '#prefix' => '<div class="js-form-item form-item">',
      '#suffix' => '</div>',
      '#markup' => $analyzer->formatMessages($messages),
    ];

    // Inform the standard button function that we want an OK button.     $form_state->set('ok_button', TRUE);
    $view->getStandardButtons($form$form_state, 'views_ui_analyze_view_form');
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    /** @var \Drupal\views_ui\ViewUI $view */
    $view = $form_state->get('view');
    $form_state->setRedirectUrl($view->toUrl('edit-form'));
  }

}
if (!empty($display['deleted'])) {
        $form['displays'][$id]['deleted'] = [
          '#type' => 'value',
          '#value' => TRUE,
        ];

        $form['displays'][$id]['#attributes']['class'][] = 'hidden';
      }

    }

    $view->getStandardButtons($form$form_state, 'views_ui_reorder_displays_form');

    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    /** @var \Drupal\views_ui\ViewUI $view */
    $view = $form_state->get('view');
    $order = [];

    
Home | Imprint | This part of the site doesn't use cookies.