Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BrowserKitDriver.php

function BrowserKitDriver::setValue

Overrides CoreDriver::setValue

File

vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php, line 409

Class

BrowserKitDriver
Symfony BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function setValue(string $xpath, $value) {
    $field = $this->getFormField($xpath);
    if ($field instanceof ChoiceFormField) {
        if (!\is_string($value) && $field->getType() === 'radio') {
            throw new DriverException('Only string values can be used for a radio input.');
        }
        if (\is_bool($value) && $field->getType() === 'select') {
            throw new DriverException('Boolean values cannot be used for a select element.');
        }
        $field->setValue($value);
        return;
    }
    if (\is_array($value) || \is_bool($value)) {
        throw new DriverException('Textual and file form fields don\'t support array or boolean values.');
    }
    $field->setValue($value);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal