public function MeetingResultForm::save in Opigno Moxtra 3.x
Same name and namespace in other branches
- 8 src/Form/MeetingResultForm.php \Drupal\opigno_moxtra\Form\MeetingResultForm::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/ MeetingResultForm.php, line 69
Class
- MeetingResultForm
- Provides a form for creating/editing a opigno_moxtra_meeting_result entity.
Namespace
Drupal\opigno_moxtra\FormCode
public function save(array $form, FormStateInterface $form_state) {
/** @var \Drupal\opigno_moxtra\MeetingResultInterface $entity */
$entity = $this->entity;
$status = parent::save($form, $form_state);
// Set status message.
$link = $entity
->toLink()
->toString();
if ($status == SAVED_UPDATED) {
$message = $this
->t('The Meeting Result %result has been updated.', [
'%result' => $link,
]);
}
else {
$message = $this
->t('The Meeting Result Workspace %result has been created.', [
'%result' => $link,
]);
}
$this
->messenger()
->addMessage($message);
// Set redirect.
$form_state
->setRedirect('entity.opigno_moxtra_meeting_result.canonical', [
'opigno_moxtra_meeting_result' => $entity
->id(),
]);
return $status;
}