public function AvatarKitServiceForm::save in Avatar Kit 8.2
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/ AvatarKitServiceForm.php, line 123
Class
- AvatarKitServiceForm
- Add and edit form for Avatar Kit service instances.
Namespace
Drupal\avatars\Form\EntityCode
public function save(array $form, FormStateInterface $form_state) : int {
/** @var \Drupal\avatars\Entity\AvatarKitServiceInterface $instance */
$instance = $this
->getEntity();
$plugin = $instance
->getPlugin();
if ($plugin) {
$subform_state = SubformState::createForSubform($form['plugin_configuration'], $form, $form_state);
$plugin
->submitConfigurationForm($form['plugin_configuration'], $subform_state);
}
$status = parent::save($form, $form_state);
if ($status === SAVED_NEW) {
$form_state
->setRedirectUrl($this
->getEntity()
->toUrl('edit-form'));
}
return $status;
}