FormFieldTrait
Helpers for setting form field values in FunctionalJavascript tests.
- Full name:
\Drupal\Tests\helper\Traits\FormFieldTrait
Methods
setFieldValue
Sets a field's value in the browser, so that its 'change' event fires.
protected setFieldValue(string $locator, string|array $value): void
Mink's setValue() doesn't trigger 'change' when it deselects every option of a multiple select, so #states and other listeners would miss it. An empty array is set with a script that triggers 'change' instead. Other values use setValue().
Parameters:
| Parameter | Type | Description |
|---|---|---|
$locator |
string | |
| The field's id, name or label, as for assertSession()->fieldExists(). | ||
$value |
string|array | |
| The value. An array for a multiple select, or an empty array to | ||
| deselect every option. |
See Also:
- https://www.drupal.org/project/drupal/issues/3367310