Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 816cf17

Browse filesBrowse files
committed
[DomCrawler] Fixed incorrect handling of image inputs
1 parent 6a4d765 commit 816cf17
Copy full SHA for 816cf17

File tree

Expand file treeCollapse file tree

2 files changed

+23
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+23
-1
lines changed

‎src/Symfony/Component/DomCrawler/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Form.php
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,24 @@ private function initialize()
384384

385385
// add submitted button if it has a valid name
386386
if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
387-
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
387+
if ('input' == $this->button->nodeName && 'image' == $this->button->getAttribute('type')) {
388+
$name = $this->button->getAttribute('name');
389+
$this->button->setAttribute('value', '0');
390+
391+
// temporarily change the name of the input node for the x coordinate
392+
$this->button->setAttribute('name', $name.'.x');
393+
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
394+
395+
// temporarily change the name of the input node for the y coordinate
396+
$this->button->setAttribute('name', $name.'.y');
397+
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
398+
399+
// restore the original name of the input node
400+
$this->button->setAttribute('name', $name);
401+
}
402+
else {
403+
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
404+
}
388405
}
389406

390407
// find form elements corresponding to the current form

‎src/Symfony/Component/DomCrawler/Tests/FormTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/FormTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ public function provideInitializeValues()
223223
<input type="submit" name="foobar" value="foobar" />',
224224
array('foobar' => array('InputFormField', 'foobar')),
225225
),
226+
array(
227+
'turns an image input into x and y fields',
228+
'<input type="image" name="bar" />',
229+
array('bar.x' => array('InputFormField', '0'), 'bar.y' => array('InputFormField', '0')),
230+
),
226231
array(
227232
'returns textareas',
228233
'<textarea name="foo">foo</textarea>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.