function Crawler::form
Returns a Form object for the first node in the list.
Throws
\InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement
File
-
vendor/
symfony/ dom-crawler/ Crawler.php, line 844
Class
- Crawler
- Crawler eases navigation of a list of \DOMNode objects.
Namespace
Symfony\Component\DomCrawlerCode
public function form(?array $values = null, ?string $method = null) : Form {
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
if (!$node instanceof \DOMElement) {
throw new \InvalidArgumentException(\sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node)));
}
$form = new Form($node, $this->uri, $method, $this->baseHref);
if (null !== $values) {
$form->setValues($values);
}
return $form;
}