function FormBuilderTest::buildTestFormStructure

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::buildTestFormStructure()

Returns a test form array for use in form builder tests.

Return value

array The form array.

1 call to FormBuilderTest::buildTestFormStructure()
TestForm::buildForm in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php

File

core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php, line 64

Class

FormBuilderTest
Tests Drupal\Core\Form\FormBuilder.

Namespace

Drupal\Tests\Core\Form

Code

public static function buildTestFormStructure() : array {
  $form['test'] = [
    '#type' => 'textfield',
    '#title' => 'Test',
  ];
  $form['options'] = [
    '#type' => 'radios',
    '#options' => [
      'foo' => 'foo',
      'bar' => 'bar',
    ],
  ];
  $form['value'] = [
    '#type' => 'value',
    '#value' => 'bananas',
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => 'Submit',
  ];
  $form['actions']['other_action'] = [
    '#type' => 'submit',
    '#name' => 'other_action',
    '#value' => 'Other action',
  ];
  return $form;
}

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