function FieldFormButtonTest::viewsFormSubmit

Same name in other branches
  1. 9 core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php \Drupal\views_test_data\Plugin\views\field\FieldFormButtonTest::viewsFormSubmit()
  2. 8.9.x core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php \Drupal\views_test_data\Plugin\views\field\FieldFormButtonTest::viewsFormSubmit()
  3. 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php \Drupal\views_test_data\Plugin\views\field\FieldFormButtonTest::viewsFormSubmit()

Submit handler for the views form.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/field/FieldFormButtonTest.php, line 68

Class

FieldFormButtonTest
A handler to provide a field that is completely custom by the administrator.

Namespace

Drupal\views_test_data\Plugin\views\field

Code

public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
    $triggering_element = $form_state->getTriggeringElement();
    if (!empty($triggering_element['#test_button'])) {
        $row_index = $triggering_element['#row_index'];
        $view_args = !empty($this->view->args) ? implode(', ', $this->view->args) : 'no arguments';
        $display = $this->view->current_display;
        $view_id = $this->view
            ->id();
        $this->messenger()
            ->addStatus("The test button at row {$row_index} for {$view_id} ({$display}) View with args: {$view_args} was submitted.");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.