[DomCrawler] Fixed creating form objects from form nodes.
This commit is contained in:
parent
83eea20bd8
commit
72d6322e25
@ -383,7 +383,7 @@ class Form extends Link implements \ArrayAccess
|
||||
$root = $document->appendChild($document->createElement('_root'));
|
||||
|
||||
// add submitted button if it has a valid name
|
||||
if ($this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
|
||||
if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
|
||||
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
|
||||
}
|
||||
|
||||
|
@ -273,6 +273,16 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($dom->getElementsByTagName('form')->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form');
|
||||
}
|
||||
|
||||
public function testGetFormNodeFromNamedForm()
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML('<html><form name="my_form"><input type="submit" /></form></html>');
|
||||
|
||||
$form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com');
|
||||
|
||||
$this->assertSame($dom->getElementsByTagName('form')->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form');
|
||||
}
|
||||
|
||||
public function testGetMethod()
|
||||
{
|
||||
$form = $this->createForm('<form><input type="submit" /></form>');
|
||||
|
Reference in New Issue
Block a user