3 namespace Drupal\form_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Defines a form for testing form element description display options.
11 * @see \Drupal\system\Tests\Form\ElementsLabelsTest::testFormDescriptions()
13 class FormTestDescriptionForm extends FormBase {
18 public function getFormId() {
19 return 'form_test_description_display';
25 public function buildForm(array $form, FormStateInterface $form_state) {
26 $form['form_textfield_test_description_before'] = [
27 '#type' => 'textfield',
28 '#title' => 'Textfield test for description before element',
29 '#description' => 'Textfield test for description before element',
30 '#description_display' => 'before',
33 $form['form_textfield_test_description_after'] = [
34 '#type' => 'textfield',
35 '#title' => 'Textfield test for description after element',
36 '#description' => 'Textfield test for description after element',
37 '#description_display' => 'after',
40 $form['form_textfield_test_description_invisible'] = [
41 '#type' => 'textfield',
42 '#title' => 'Textfield test for visually-hidden description',
43 '#description' => 'Textfield test for visually-hidden description',
44 '#description_display' => 'invisible',
53 public function submitForm(array &$form, FormStateInterface $form_state) {
54 // The test that uses this form does not submit the form so this is empty.