You are here

public function ProfileForm::execute in Entity Legal 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityLegal/ProfileForm.php \Drupal\entity_legal\Plugin\EntityLegal\ProfileForm::execute()
  2. 4.0.x src/Plugin/EntityLegal/ProfileForm.php \Drupal\entity_legal\Plugin\EntityLegal\ProfileForm::execute()

Execute callback for Entity Legal method plugin.

Parameters

array $context: Contextual information for plugin to execute on.

Overrides EntityLegalPluginInterface::execute

1 call to ProfileForm::execute()
ProfileFormEmbedded::execute in src/Plugin/EntityLegal/ProfileFormEmbedded.php
Execute callback for Entity Legal method plugin.
1 method overrides ProfileForm::execute()
ProfileFormEmbedded::execute in src/Plugin/EntityLegal/ProfileFormEmbedded.php
Execute callback for Entity Legal method plugin.

File

src/Plugin/EntityLegal/ProfileForm.php, line 22

Class

ProfileForm
Method class for displaying a checkbox on the user register form.

Namespace

Drupal\entity_legal\Plugin\EntityLegal

Code

public function execute(array &$context = []) {
  if (!empty($this->documents)) {
    $context['form']['actions']['submit']['#submit'][] = [
      get_class($this),
      'submitForm',
    ];

    /** @var \Drupal\entity_legal\EntityLegalDocumentInterface $document */
    foreach ($this->documents as $document) {
      $context['form']['#cache']['tags'][] = "entity_legal_document:{$document->id()}";
      $context['form']["legal_{$document->id()}"] = [
        '#type' => 'checkbox',
        '#title' => $document
          ->getAcceptanceLabel(),
        '#default_value' => $document
          ->userHasAgreed(),
        '#required' => TRUE,
      ];
      $context['form']['#entity_legal'] = $this;
    }
  }
}