You are here

private function BrowserKitDriver::mergeForms in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php \Behat\Mink\Driver\BrowserKitDriver::mergeForms()

Merges second form values into first one.

Parameters

Form $to merging target:

Form $from merging source:

1 call to BrowserKitDriver::mergeForms()
BrowserKitDriver::submit in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php

File

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

Class

BrowserKitDriver
Symfony2 BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

private function mergeForms(Form $to, Form $from) {
  foreach ($from
    ->all() as $name => $field) {
    $fieldReflection = new \ReflectionObject($field);
    $nodeReflection = $fieldReflection
      ->getProperty('node');
    $valueReflection = $fieldReflection
      ->getProperty('value');
    $nodeReflection
      ->setAccessible(true);
    $valueReflection
      ->setAccessible(true);
    $isIgnoredField = $field instanceof InputFormField && in_array($nodeReflection
      ->getValue($field)
      ->getAttribute('type'), array(
      'submit',
      'button',
      'image',
    ), true);
    if (!$isIgnoredField) {
      $valueReflection
        ->setValue($to[$name], $valueReflection
        ->getValue($field));
    }
  }
}