LongIdForm.php in CAPTCHA 8
File
modules/captcha_long_form_id_test/src/Form/LongIdForm.php
View source
<?php
namespace Drupal\captcha_long_form_id_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class LongIdForm extends FormBase {
public function getFormId() {
return 'this_formid_is_intentionally_longer_than_64_characters_to_test_captcha';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['text_field'] = [
'#type' => 'textfield',
'#title' => $this
->t('Text Field'),
'#maxlength' => 64,
'#size' => 64,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state
->getValues() as $key => $value) {
$this
->messenger()
->addMessage($key . ': ' . $value);
}
}
}