You are here

public function DataPolicyForm::buildForm in Data Policy 8

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

1 call to DataPolicyForm::buildForm()
DataPolicyRevisionEdit::buildForm in src/Form/DataPolicyRevisionEdit.php
Form constructor.
1 method overrides DataPolicyForm::buildForm()
DataPolicyRevisionEdit::buildForm in src/Form/DataPolicyRevisionEdit.php
Form constructor.

File

src/Form/DataPolicyForm.php, line 19

Class

DataPolicyForm
Default form controller for Data policy.

Namespace

Drupal\data_policy\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  if ($this
    ->clearMessage()) {
    $form['revision_log_message']['widget'][0]['value']['#default_value'] = '';
  }
  $entity_id = $this
    ->config('data_policy.data_policy')
    ->get('entity_id');
  $is_new = empty($entity_id);
  $form['active_revision'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Active'),
    '#description' => $this
      ->t('When this field is checked, after submitting the form, a new revision will be created which will be marked active.'),
    '#default_value' => $is_new,
    '#disabled' => $is_new,
    '#weight' => 10,
  ];
  $form['new_revision'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Create new revision'),
    '#default_value' => TRUE,
    '#disabled' => TRUE,
    '#weight' => 10,
  ];
  if (isset($form['langcode'])) {
    $form['langcode']['widget'][0]['value']['#languages'] = LanguageInterface::STATE_CONFIGURABLE;
  }
  return $form;
}