// restore the original name of the input node
$this->button->
setAttribute('name',
$name);
} else { $this->
set(new Field\
InputFormField($this->button
));
} } // find form elements corresponding to the current form
if ($this->node->
hasAttribute('id'
)) { // corresponding elements are either descendants or have a matching HTML5 form attribute
$formId = Crawler::
xpathLiteral($this->node->
getAttribute('id'
));
$fieldNodes =
$xpath->
query(sprintf('( descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)] )[not(ancestor::template)]',
$formId));
foreach ($fieldNodes as $node) { $this->
addField($node);
} } else { // do the xpath query with $this->node as the context node, to only find descendant elements
// however, descendant elements with form attribute are not part of this form
$fieldNodes =
$xpath->
query('( descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)] )[not(ancestor::template)]',
$this->node
);
foreach ($fieldNodes as $node) { $this->
addField($node);
}