You are here

public function FormElementMaxlengthTest::buildForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Form/FormElementMaxlengthTest.php \Drupal\Tests\system\Kernel\Form\FormElementMaxlengthTest::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

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

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;
}