protected function Form::setNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Form.php \Symfony\Component\DomCrawler\Form::setNode()
Sets the node for the form.
Expects a 'submit' button \DOMElement and finds the corresponding form element, or the form element itself.
Parameters
\DOMElement $node A \DOMElement instance:
Throws
\LogicException If given node is not a button or input or does not have a form ancestor
Overrides Link::setNode
File
- vendor/
symfony/ dom-crawler/ Form.php, line 361
Class
- Form
- Form represents an HTML form.
Namespace
Symfony\Component\DomCrawlerCode
protected function setNode(\DOMElement $node) {
$this->button = $node;
if ('button' === $node->nodeName || 'input' === $node->nodeName && in_array(strtolower($node
->getAttribute('type')), array(
'submit',
'button',
'image',
))) {
if ($node
->hasAttribute('form')) {
// if the node has the HTML5-compliant 'form' attribute, use it
$formId = $node
->getAttribute('form');
$form = $node->ownerDocument
->getElementById($formId);
if (null === $form) {
throw new \LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId));
}
$this->node = $form;
return;
}
// we loop until we find a form ancestor
do {
if (null === ($node = $node->parentNode)) {
throw new \LogicException('The selected node does not have a form ancestor.');
}
} while ('form' !== $node->nodeName);
}
elseif ('form' !== $node->nodeName) {
throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
}
$this->node = $node;
}