public function DisclaimerEmailMatchForm::buildForm in Disclaimer 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 FormInterface::buildForm
File
- src/
Form/ DisclaimerEmailMatchForm.php, line 56
Class
- DisclaimerEmailMatchForm
- Class DisclaimerEmailMatchForm.
Namespace
Drupal\disclaimer\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$ajax_wrapper_id = Html::getUniqueId('box-container');
$form['#prefix'] = '<div id="' . $ajax_wrapper_id . '">';
$form['#suffix'] = '</div>';
$form['email'] = [
'#type' => 'email',
'#title' => $this
->t('E-mail'),
'#weight' => 10,
];
$form['block_id'] = [
'#type' => 'hidden',
'#default_value' => '',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
'#weight' => 20,
'#ajax' => [
'callback' => '::ajaxSubmit',
'wrapper' => $ajax_wrapper_id,
],
];
$form['leave'] = [
'#type' => 'button',
'#name' => 'leave',
'#value' => $this
->t('Leave'),
'#weight' => 30,
'#ajax' => [
'callback' => '::leaveForm',
'wrapper' => $ajax_wrapper_id,
],
];
return $form;
}