function TableDragTestForm::submitForm

Same name in other branches
  1. 9 core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php \Drupal\tabledrag_test\Form\TableDragTestForm::submitForm()
  2. 8.9.x core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php \Drupal\tabledrag_test\Form\TableDragTestForm::submitForm()
  3. 11.x core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php \Drupal\tabledrag_test\Form\TableDragTestForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php, line 183

Class

TableDragTestForm
Provides a form for draggable table testing.

Namespace

Drupal\tabledrag_test\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $operation = $form_state->getTriggeringElement()['#op'] ?? 'save';
    switch ($operation) {
        case 'reset':
            $this->state
                ->set('tabledrag_test_table', array_flip(range(1, 5)));
            break;
        default:
            $test_table = [];
            foreach ($form_state->getValue('table') as $row) {
                $test_table[$row['id']] = $row;
            }
            $this->state
                ->set('tabledrag_test_table', $test_table);
            break;
    }
}

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