You are here

public function ContentUpdateConfirmForm::buildForm in GatherContent 8.4

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 ContentConfirmForm::buildForm

File

gathercontent_ui/src/Form/ContentUpdateConfirmForm.php, line 55

Class

ContentUpdateConfirmForm
Provides a node deletion confirmation form.

Namespace

Drupal\gathercontent_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $import_config = $this
    ->configFactory()
    ->get('gathercontent.import');
  $form['node_update_method'] = [
    '#type' => 'radios',
    '#required' => TRUE,
    '#title' => $this
      ->t('Content update method'),
    '#default_value' => $import_config
      ->get('node_update_method'),
    '#options' => [
      NodeUpdateMethod::ALWAYS_CREATE => $this
        ->t('Always create new Content'),
      NodeUpdateMethod::UPDATE_IF_NOT_CHANGED => $this
        ->t('Create new Content if it has changed since the last import'),
      NodeUpdateMethod::ALWAYS_UPDATE => $this
        ->t('Always update existing Content'),
    ],
  ];
  $form['node_create_new_revision'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Create new revision'),
    '#default_value' => $import_config
      ->get('node_create_new_revision'),
    '#states' => [
      'visible' => [
        ':input[name="node_update_method"]' => [
          'value' => NodeUpdateMethod::ALWAYS_UPDATE,
        ],
      ],
    ],
  ];
  return $form;
}