public function PagererPresetEditForm::save in Pagerer 8
Same name and namespace in other branches
- 8.2 src/Form/PagererPresetEditForm.php \Drupal\pagerer\Form\PagererPresetEditForm::save()
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- src/
Form/ PagererPresetEditForm.php, line 177
Class
- PagererPresetEditForm
- Base form handler for Pagerer Presets.
Namespace
Drupal\pagerer\FormCode
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
$trigger = $form_state
->getTriggeringElement()['#name'];
if (strpos($trigger, 'config', 0) === 0) {
$e = explode('_', $trigger);
$pane = $e[1];
$form_state
->setRedirect('entity.pagerer_preset.pane_edit_form', [
'pagerer_preset' => $this->entity
->id(),
'pane' => $pane,
]);
}
elseif (strpos($trigger, 'reset', 0) === 0) {
$e = explode('_', $trigger);
$pane = $e[1];
$form_state
->setRedirect('entity.pagerer_preset.pane_reset_form', [
'pagerer_preset' => $this->entity
->id(),
'pane' => $pane,
]);
}
else {
$this->messenger
->addMessage($this
->t('Changes to the pager %label have been saved.', [
'%label' => $this->entity
->label(),
]));
}
}