function TermTranslationHandler::entityFormSave

Same name in other branches
  1. 9 core/modules/taxonomy/src/TermTranslationHandler.php \Drupal\taxonomy\TermTranslationHandler::entityFormSave()
  2. 10 core/modules/taxonomy/src/TermTranslationHandler.php \Drupal\taxonomy\TermTranslationHandler::entityFormSave()
  3. 11.x core/modules/taxonomy/src/TermTranslationHandler.php \Drupal\taxonomy\TermTranslationHandler::entityFormSave()

Form submission handler for TermTranslationHandler::entityFormAlter().

This handles the save action.

See also

\Drupal\Core\Entity\EntityForm::build()

File

core/modules/taxonomy/src/TermTranslationHandler.php, line 32

Class

TermTranslationHandler
Defines the translation handler for terms.

Namespace

Drupal\taxonomy

Code

public function entityFormSave(array $form, FormStateInterface $form_state) {
    if ($this->getSourceLangcode($form_state)) {
        $entity = $form_state->getFormObject()
            ->getEntity();
        // We need a redirect here, otherwise we would get an access denied page,
        // since the current URL would be preserved and we would try to add a
        // translation for a language that already has a translation.
        $form_state->setRedirectUrl($entity->toUrl('edit-form'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.