function FormTestValidateRequiredNoTitleForm::buildForm

Same name in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php \Drupal\form_test\Form\FormTestValidateRequiredNoTitleForm::buildForm()
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php \Drupal\form_test\Form\FormTestValidateRequiredNoTitleForm::buildForm()
  3. 11.x core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php \Drupal\form_test\Form\FormTestValidateRequiredNoTitleForm::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/modules/form_test/src/Form/FormTestValidateRequiredNoTitleForm.php, line 25

Class

FormTestValidateRequiredNoTitleForm
Form constructor to test the #required property without #title.

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['textfield'] = [
        '#type' => 'textfield',
        '#required' => TRUE,
    ];
    $form['actions'] = [
        '#type' => 'actions',
    ];
    $form['actions']['submit'] = [
        '#type' => 'submit',
        '#value' => 'Submit',
    ];
    return $form;
}

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