function FormStateValuesTraitTest::testSetValueForElement
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testSetValueForElement()
- 10 core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testSetValueForElement()
- 11.x core/tests/Drupal/Tests/Core/Form/FormStateValuesTraitTest.php \Drupal\Tests\Core\Form\FormStateValuesTraitTest::testSetValueForElement()
Tests that setting the value for an element adds to the values.
@covers ::setValueForElement
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateValuesTraitTest.php, line 20
Class
- FormStateValuesTraitTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormStateValuesTrait.php/trait/FormStateValuesTrait/8.9.x" title="Provides methods to manage form state values." class="local">\Drupal\Core\Form\FormStateValuesTrait</a>
Namespace
Drupal\Tests\Core\FormCode
public function testSetValueForElement() {
$element = [
'#parents' => [
'foo',
'bar',
],
];
$value = $this->randomMachineName();
$form_state = new FormStateValuesTraitStub();
$form_state->setValueForElement($element, $value);
$expected = [
'foo' => [
'bar' => $value,
],
];
$this->assertSame($expected, $form_state->getValues());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.