public function RelationTypeForm::save in Relation 8
Same name and namespace in other branches
- 8.2 src/RelationTypeForm.php \Drupal\relation\RelationTypeForm::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/
RelationTypeForm.php, line 201 - Definition of Drupal\relation\RelationTypeForm.
Class
- RelationTypeForm
- Form controller for relation edit form.
Namespace
Drupal\relationCode
public function save(array $form, FormStateInterface $form_state) {
$relation_type = $this->entity;
$save_message = $relation_type
->isNew() ? t('The %relation_type relation type has been created.', array(
'%relation_type' => $relation_type
->id(),
)) : t('The %relation_type relation type has been saved.', array(
'%relation_type' => $relation_type
->id(),
));
if ($relation_type
->save()) {
drupal_set_message($save_message);
$form_state
->setRedirectUrl($relation_type
->urlInfo());
}
else {
drupal_set_message(t('Error saving relation type.', 'error'));
}
}