/** * Form submission handler for TermTranslationHandler::entityFormAlter(). * * This handles the save action. * * @see \Drupal\Core\Entity\EntityForm::build(). */ function entityFormSave(array $form, array &$form_state) { if ($this->getSourceLangcode($form_state)) { $entity = content_translation_form_controller($form_state)->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['redirect_route'] = $entity->urlInfo('edit-form'); } }
/** * Form submission handler for ProfileTranslationHandler::entityFormAlter(). * * This handles the save action. * * @see \Drupal\Core\Entity\EntityForm::build(). */ function entityFormSave(array $form, FormStateInterface $form_state) { if ($this->getSourceLangcode($form_state)) { $entity = content_translation_form_controller($form_state)->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->urlInfo()); } }
/** * {@inheritdoc} */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if (isset($form_state['values']['content_translation'])) { $form_controller = content_translation_form_controller($form_state); $translation =& $form_state['values']['content_translation']; $translation['status'] = $form_controller->getEntity()->isPublished(); // $form['content_translation']['name'] is the equivalent field // for translation author uid. $translation['name'] = $form_state['values']['uid']; $translation['created'] = $form_state['values']['created']; } parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state); }
/** * Form submission handler for ContentTranslationHandler::entityFormAlter(). * * Takes care of content translation deletion. */ function entityFormDeleteTranslation($form, &$form_state) { $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); $path = $entity->getSystemPath('drupal:content-translation-overview'); $form_langcode = $form_controller->getFormLangcode($form_state); $form_state['redirect'] = $path . '/delete/' . $form_langcode; }