You are here

public function IndividualTypeForm::save in CRM Core 8.2

Same name and namespace in other branches
  1. 8.3 modules/crm_core_contact/src/Form/IndividualTypeForm.php \Drupal\crm_core_contact\Form\IndividualTypeForm::save()
  2. 8 modules/crm_core_contact/src/Form/IndividualTypeForm.php \Drupal\crm_core_contact\Form\IndividualTypeForm::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/crm_core_contact/src/Form/IndividualTypeForm.php, line 111

Class

IndividualTypeForm
Form for edit individual types.

Namespace

Drupal\crm_core_contact\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $type = $this->entity;
  $status = $type
    ->save();
  $t_args = array(
    '%name' => $type
      ->label(),
    'link' => \Drupal::url('entity.crm_core_individual_type.collection'),
  );
  if ($status == SAVED_UPDATED) {
    drupal_set_message($this
      ->t('The individual type %name has been updated.', $t_args));
  }
  elseif ($status == SAVED_NEW) {
    drupal_set_message($this
      ->t('The individual type %name has been added.', $t_args));
    \Drupal::logger('crm_core_individual')
      ->notice('Added individual type %name.', $t_args);
  }
  $form_state
    ->setRedirect('entity.crm_core_individual_type.collection');
}