You are here

private function BrowserKitDriver::getFormNode 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::getFormNode()

Parameters

\DOMElement $element:

Return value

\DOMElement

Throws

DriverException if the form node cannot be found

2 calls to BrowserKitDriver::getFormNode()
BrowserKitDriver::getFormField in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php
Returns form field from XPath query.
BrowserKitDriver::resetForm in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php

File

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

Class

BrowserKitDriver
Symfony2 BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

private function getFormNode(\DOMElement $element) {
  if ($element
    ->hasAttribute('form')) {
    $formId = $element
      ->getAttribute('form');
    $formNode = $element->ownerDocument
      ->getElementById($formId);
    if (null === $formNode || 'form' !== $formNode->nodeName) {
      throw new DriverException(sprintf('The selected node has an invalid form attribute (%s).', $formId));
    }
    return $formNode;
  }
  $formNode = $element;
  do {

    // use the ancestor form element
    if (null === ($formNode = $formNode->parentNode)) {
      throw new DriverException('The selected node does not have a form ancestor.');
    }
  } while ('form' !== $formNode->nodeName);
  return $formNode;
}