class FormTestDescriptionForm

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php \Drupal\form_test\Form\FormTestDescriptionForm

Defines a form for testing form element description display options.

@internal

Hierarchy

Expanded class hierarchy of FormTestDescriptionForm

See also

\Drupal\system\Tests\Form\ElementsLabelsTest::testFormDescriptions()

1 string reference to 'FormTestDescriptionForm'
form_test.routing.yml in core/modules/system/tests/modules/form_test/form_test.routing.yml
core/modules/system/tests/modules/form_test/form_test.routing.yml

File

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

Namespace

Drupal\form_test\Form
View source
class FormTestDescriptionForm extends FormBase {
  
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'form_test_description_display';
  }
  
  /**
   * {@inheritdoc}
   */
  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;
  }
  
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // The test that uses this form does not submit the form so this is empty.
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.