Newer
Older
Alex Pott
committed
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Defines a form for testing form element description display options.
*
* @internal
*
Alex Pott
committed
* @see \Drupal\system\Tests\Form\ElementsLabelsTest::testFormDescriptions()
*/
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'] = [
Alex Pott
committed
'#type' => 'textfield',
'#title' => 'Textfield test for description before element',
'#description' => 'Textfield test for description before element',
'#description_display' => 'before',
];
Alex Pott
committed
$form['form_textfield_test_description_after'] = [
Alex Pott
committed
'#type' => 'textfield',
'#title' => 'Textfield test for description after element',
'#description' => 'Textfield test for description after element',
'#description_display' => 'after',
];
Alex Pott
committed
$form['form_textfield_test_description_invisible'] = [
Alex Pott
committed
'#type' => 'textfield',
'#title' => 'Textfield test for visually-hidden description',
'#description' => 'Textfield test for visually-hidden description',
'#description_display' => 'invisible',
];
Alex Pott
committed
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.
}
}