function NodeRevisionRevertTranslationForm::buildForm

Same name and namespace in other branches
  1. 9 core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php \Drupal\node\Form\NodeRevisionRevertTranslationForm::buildForm()
  2. 8.9.x core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php \Drupal\node\Form\NodeRevisionRevertTranslationForm::buildForm()
  3. 10 core/modules/node/src/Form/NodeRevisionRevertTranslationForm.php \Drupal\node\Form\NodeRevisionRevertTranslationForm::buildForm()

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;
}

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