bug #9884 [DomCrawler] Fixed creating form objects from named form nodes (jakzal)
This PR was merged into the 2.3 branch.
Discussion
----------
[DomCrawler] Fixed creating form objects from named form nodes
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #9619
| License | MIT
| Doc PR | -
Commits
-------
72d6322
[DomCrawler] Fixed creating form objects from form nodes.
This commit is contained in:
commit
7fc0a53e0d
@ -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