public function CertificateEntityForm::save in Certificate 4.x
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/ CertificateEntityForm.php, line 41
Class
- CertificateEntityForm
- Form for certificate template.
Namespace
Drupal\certificate\FormCode
public function save(array $form, FormStateInterface $form_state) {
$certificate = $this->entity;
$insert = $certificate
->isNew();
parent::save($form, $form_state);
$t_args = [
':title' => $certificate
->label(),
];
if ($insert) {
$this
->messenger()
->addStatus($this
->t(':title has been created.', $t_args));
//$form_state->setRedirect('course.outline', ['course' => $this->entity->id()]);
}
else {
$this
->messenger()
->addStatus($this
->t(':title has been updated.', $t_args));
}
}