You are here

function test_form_id in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc \test_form_id()
  2. 9 core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc \test_form_id()

Creates a test form.

Return value

array The form array

1 call to test_form_id()
TestForm::buildForm in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Form constructor.
27 string references to 'test_form_id'
FormBuilderTest::providerTestFormTokenCacheability in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Data provider for testFormTokenCacheability.
FormBuilderTest::testBuildFormWithObject in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the buildForm() method with a form object.
FormBuilderTest::testBuildFormWithString in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the buildForm() method with a string based form ID.
FormBuilderTest::testBuildFormWithTriggeringElement in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests whether the triggering element is properly identified.
FormBuilderTest::testExceededFileSize in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
@covers ::buildForm

... See full list

File

core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc, line 14
Functions in the global namespace for \Drupal\Tests\Core\Form\FormTestBase.

Code

function test_form_id() {
  $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',
  ];
  return $form;
}