function FormElementMaxlengthTest::buildForm

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php \Drupal\Tests\system\Kernel\Form\FormElementMaxlengthTest::buildForm()
  2. 8.9.x core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php \Drupal\Tests\system\Kernel\Form\FormElementMaxlengthTest::buildForm()
  3. 11.x core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php \Drupal\Tests\system\Kernel\Form\FormElementMaxlengthTest::buildForm()

Overrides FormInterface::buildForm

File

core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php, line 35

Class

FormElementMaxlengthTest
Tests the maxlength HTML attribute on form elements.

Namespace

Drupal\Tests\system\Kernel\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['title'] = [
        '#type' => 'textfield',
        '#maxlength' => 255,
    ];
    $form['description'] = [
        '#type' => 'textarea',
        '#maxlength' => 255,
    ];
    $form['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.