public function QueueStorageEntityForm::save in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/custom/social_queue_storage/src/Form/QueueStorageEntityForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityForm::save()
- 8.8 modules/custom/social_queue_storage/src/Form/QueueStorageEntityForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityForm::save()
- 10.3.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityForm::save()
- 10.1.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityForm::save()
- 10.2.x modules/custom/social_queue_storage/src/Form/QueueStorageEntityForm.php \Drupal\social_queue_storage\Form\QueueStorageEntityForm::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
- modules/
custom/ social_queue_storage/ src/ Form/ QueueStorageEntityForm.php, line 46
Class
- QueueStorageEntityForm
- Form controller for Queue storage entity edit forms.
Namespace
Drupal\social_queue_storage\FormCode
public function save(array $form, FormStateInterface $form_state) {
// Possibility to add additional data to the entity upon saving.
$entity = $this->entity;
$status = parent::save($form, $form_state);
// Add status message depending on the created state of the entity.
switch ($status) {
case SAVED_NEW:
$this
->messenger()
->addMessage($this
->t('Created the %label Queue storage entity.', [
'%label' => $entity
->label(),
]));
break;
default:
$this
->messenger()
->addMessage($this
->t('Saved the %label Queue storage entity.', [
'%label' => $entity
->label(),
]));
}
$form_state
->setRedirect('entity.queue_storage_entity.canonical', [
'queue_storage_entity' => $entity
->id(),
]);
}