public function TableDragTestForm::submitForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php \Drupal\tabledrag_test\Form\TableDragTestForm::submitForm()
- 9 core/modules/system/tests/modules/tabledrag_test/src/Form/TableDragTestForm.php \Drupal\tabledrag_test\Form\TableDragTestForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
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\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$operation = isset($form_state
->getTriggeringElement()['#op']) ? $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;
}
}