You are here

public function EntityLegalDocumentAcceptanceForm::buildForm in Entity Legal 4.0.x

Same name and namespace in other branches
  1. 8.2 src/Form/EntityLegalDocumentAcceptanceForm.php \Drupal\entity_legal\Form\EntityLegalDocumentAcceptanceForm::buildForm()
  2. 3.0.x src/Form/EntityLegalDocumentAcceptanceForm.php \Drupal\entity_legal\Form\EntityLegalDocumentAcceptanceForm::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 FormInterface::buildForm

File

src/Form/EntityLegalDocumentAcceptanceForm.php, line 67

Class

EntityLegalDocumentAcceptanceForm
Provides a confirmation form for deleting a custom block entity.

Namespace

Drupal\entity_legal\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $has_agreed = $this->document
    ->userHasAgreed();
  $form['agree'] = [
    '#title' => $this->document
      ->getAcceptanceLabel(),
    '#type' => 'checkbox',
    '#required' => TRUE,
    '#default_value' => $has_agreed,
    '#disabled' => $has_agreed,
  ];
  $form['submit'] = [
    '#value' => t('Submit'),
    '#type' => 'submit',
    '#access' => !$has_agreed,
  ];
  return $form;
}