You are here

public function FormTestDescriptionForm::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php \Drupal\form_test\Form\FormTestDescriptionForm::buildForm()
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php \Drupal\form_test\Form\FormTestDescriptionForm::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

core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php, line 27

Class

FormTestDescriptionForm
Defines a form for testing form element description display options.

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['form_textfield_test_description_before'] = [
    '#type' => 'textfield',
    '#title' => 'Textfield test for description before element',
    '#description' => 'Textfield test for description before element',
    '#description_display' => 'before',
  ];
  $form['form_textfield_test_description_after'] = [
    '#type' => 'textfield',
    '#title' => 'Textfield test for description after element',
    '#description' => 'Textfield test for description after element',
    '#description_display' => 'after',
  ];
  $form['form_textfield_test_description_invisible'] = [
    '#type' => 'textfield',
    '#title' => 'Textfield test for visually-hidden description',
    '#description' => 'Textfield test for visually-hidden description',
    '#description_display' => 'invisible',
  ];
  return $form;
}