You are here

public function RegistrantTypeForm::save in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Form/Entity/RegistrantTypeForm.php \Drupal\rng\Form\Entity\RegistrantTypeForm::save()
  2. 3.x src/Form/Entity/RegistrantTypeForm.php \Drupal\rng\Form\Entity\RegistrantTypeForm::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/Entity/RegistrantTypeForm.php, line 63

Class

RegistrantTypeForm
Form controller for Registrant types.

Namespace

Drupal\rng\Form\Entity

Code

public function save(array $form, FormStateInterface $form_state) {
  $registrant_type = $this
    ->getEntity();
  $status = $registrant_type
    ->save();
  $t_args = [
    '%label' => $registrant_type
      ->label(),
  ];
  if ($status === SAVED_NEW) {
    $this
      ->logger('rng')
      ->notice('%label registrant type was added.', $t_args);
    drupal_set_message($this
      ->t('%label registrant type was added.', $t_args));
  }
  else {
    $this
      ->logger('rng')
      ->notice('%label registrant type has been updated.', $t_args);
    drupal_set_message($this
      ->t('%label registrant type has been updated.', $t_args));
  }
  $form_state
    ->setRedirect('entity.registrant_type.collection');
}