function MachineNameTest::buildForm
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- 
              core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ MachineNameTest.php, line 30  
Class
- MachineNameTest
 - @coversDefaultClass \Drupal\Core\Render\Element\MachineName[[api-linebreak]] @group Render
 
Namespace
Drupal\KernelTests\Core\Render\ElementCode
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.