function MachineNameTest::buildForm

Same name and namespace 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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21MachineName.php/class/MachineName/11.x" title="Provides a machine name render element." class="local">\Drupal\Core\Render\Element\MachineName</a> @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.