You are here

public function NodeRevisionRevertTranslationForm::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php \Drupal\node\Form\NodeRevisionRevertTranslationForm::buildForm()

Form constructor.

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

array The form structure.

Overrides NodeRevisionRevertForm::buildForm

File

core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php, line 87

Class

NodeRevisionRevertTranslationForm
Provides a form for reverting a node revision for a single translation.

Namespace

Drupal\node\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL, $langcode = NULL) {
  $this->langcode = $langcode;
  $form = parent::buildForm($form, $form_state, $node_revision);

  // Unless untranslatable fields are configured to affect only the default
  // translation, we need to ask the user whether they should be included in
  // the revert process.
  $default_translation_affected = $this->revision
    ->isDefaultTranslationAffectedOnly();
  $form['revert_untranslated_fields'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Revert content shared among translations'),
    '#default_value' => $default_translation_affected && $this->revision
      ->getTranslation($this->langcode)
      ->isDefaultTranslation(),
    '#access' => !$default_translation_affected,
  ];
  return $form;
}