/** * {@inheritdoc} */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); // Move the translation fieldset to a vertical tab. if (isset($form['translation'])) { $form['translation'] += array('#group' => 'additional_settings', '#weight' => 100, '#attributes' => array('class' => array('block-content-translation-options'))); } }
/** * {@inheritdoc} */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if ($form_state->hasValue('content_translation')) { $translation =& $form_state->getValue('content_translation'); /** @var \Drupal\comment\CommentInterface $entity */ $translation['status'] = $entity->isPublished(); $translation['name'] = $entity->getAuthorName(); } parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state); }
/** * {@inheritdoc} */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if ($form_state->hasValue('content_translation')) { $translation =& $form_state->getValue('content_translation'); $translation['status'] = $entity->isPublished(); $account = $entity->uid->entity; $translation['uid'] = $account ? $account->id() : 0; $translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O'); } parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state); }
/** * {@inheritdoc} */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if ($form_state->hasValue('content_translation')) { $translation =& $form_state->getValue('content_translation'); $translation['status'] = $entity->isPublished(); // $form['content_translation']['name'] is the equivalent field // for translation author uid. $account = $entity->uid->entity; $translation['name'] = $account ? $account->getUsername() : ''; $translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O'); } parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state); }
/** * {@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); }
/** * {@inheritdoc} */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave'); }