function test_form_id

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc \test_form_id()
  2. 10 core/tests/Drupal/Tests/Core/Form/fixtures/form_base_test.inc \test_form_id()
  3. 11.x 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

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

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