function TableDragExampleResetForm::submitForm
File
-
modules/tabledrag_example/src/Form/TableDragExampleResetForm.php, line 88
Class
- TableDragExampleResetForm
- Table drag example reset form.
Namespace
Drupal\tabledrag_example\Form
Code
public function submitForm(array &$form, FormStateInterface $form_state) {
$data = Fixtures::getSampleItems();
foreach ($data as $id => $item) {
$id++;
$this->database
->update('tabledrag_example')
->fields([
'weight' => 0,
'pid' => 0,
'description' => $item['description'],
'item_group' => $item['item_group'],
])
->condition('id', $id, '=')
->execute();
}
$this->messenger()
->addMessage($this->t('Data for TableDrag Example has been reset.'), 'status');
$form_state->setRedirect('tabledrag_example.description');
}