public function OrganizationTypeForm::save in CRM Core 8
Same name and namespace in other branches
- 8.3 modules/crm_core_contact/src/Form/OrganizationTypeForm.php \Drupal\crm_core_contact\Form\OrganizationTypeForm::save()
- 8.2 modules/crm_core_contact/src/Form/OrganizationTypeForm.php \Drupal\crm_core_contact\Form\OrganizationTypeForm::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/ OrganizationTypeForm.php, line 113
Class
- OrganizationTypeForm
- Class OrganizationTypeForm.
Namespace
Drupal\crm_core_contact\FormCode
public function save(array $form, FormStateInterface $form_state) {
$type = $this->entity;
$status = $type
->save();
if ($status == SAVED_UPDATED) {
drupal_set_message($this
->t('The organization type %name has been updated.', [
'%name' => $type
->label(),
]));
}
elseif ($status == SAVED_NEW) {
drupal_set_message($this
->t('The organization type %name has been added.', [
'%name' => $type
->label(),
]));
\Drupal::logger('crm_core_organization')
->notice('Added organization type %name.', [
'%name' => $type
->label(),
]);
}
$form_state
->setRedirect('entity.crm_core_organization_type.collection');
}