FormTestDescriptionForm.php in Drupal 10
File
core/modules/system/tests/modules/form_test/src/Form/FormTestDescriptionForm.php
View source
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class FormTestDescriptionForm extends FormBase {
public function getFormId() {
return 'form_test_description_display';
}
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;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}