function MachineNameTest::buildForm

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Render/Element/MachineNameTest.php \Drupal\KernelTests\Core\Render\Element\MachineNameTest::buildForm()
  2. 10 core/tests/Drupal/KernelTests/Core/Render/Element/MachineNameTest.php \Drupal\KernelTests\Core\Render\Element\MachineNameTest::buildForm()

Overrides FormInterface::buildForm

File

core/tests/Drupal/KernelTests/Core/Render/Element/MachineNameTest.php, line 32

Class

MachineNameTest
@coversDefaultClass \Drupal\Core\Render\Element\MachineName @group Render

Namespace

Drupal\KernelTests\Core\Render\Element

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $element = [
        '#id' => 'test',
        '#type' => 'machine_name',
        '#machine_name' => [
            'source' => [
                'test_source',
            ],
        ],
        '#name' => 'test_machine_name',
        '#default_value' => NULL,
    ];
    $complete_form = [
        'test_machine_name' => $element,
        'test_source' => [
            '#type' => 'textfield',
        ],
    ];
    return $complete_form;
}

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