function ComponentAsFormElementTest::submitForm

File

core/tests/Drupal/KernelTests/Components/ComponentAsFormElementTest.php, line 177

Class

ComponentAsFormElementTest
Tests the correct rendering of components in form.

Namespace

Drupal\KernelTests\Components

Code

public function submitForm(array &$form, FormStateInterface $form_state) : void {
  // Check that submitted data are present (set with #default_value).
  $data = [
    'sdc_input' => '',
    'sdc_input_basic' => 'test_data_default_value_basic',
    'sdc_input_with_label' => '',
    'sdc_input_with_default_value' => 'test_data_default_value',
    'sdc_input_with_value' => 'test_data_value',
    'sdc_input_with_value_and_default_value' => 'test_data_value',
    'sdc_input_with_id_as_prop' => '',
    'sdc_input_with_id_as_prop_attributes' => '',
  ];
  foreach ($data as $key => $value) {
    $this->assertSame($value, $form_state->getValue($key));
  }
}

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