public function EmailForm::save in Courier 2.x
Same name and namespace in other branches
- 8 src/Form/EmailForm.php \Drupal\courier\Form\EmailForm::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/ EmailForm.php, line 55
Class
- EmailForm
- Form controller for email.
Namespace
Drupal\courier\FormCode
public function save(array $form, FormStateInterface $form_state) {
$email = $this->entity;
$is_new = $email
->isNew();
$email
->save();
$t_args = [
'%label' => $email
->label(),
];
if ($is_new) {
$this
->messenger()
->addMessage($this
->t('Email %label has been created.', $t_args));
}
else {
$this
->messenger()
->addMessage($this
->t('Email %label was updated.', $t_args));
}
}