diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php
index a127227974d89..2649d6d33b30c 100644
--- a/src/Symfony/Component/DomCrawler/Form.php
+++ b/src/Symfony/Component/DomCrawler/Form.php
@@ -384,7 +384,24 @@ private function initialize()
// add submitted button if it has a valid name
if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) {
- $this->set(new Field\InputFormField($document->importNode($this->button, true)));
+ if ('input' == $this->button->nodeName && 'image' == $this->button->getAttribute('type')) {
+ $name = $this->button->getAttribute('name');
+ $this->button->setAttribute('value', '0');
+
+ // temporarily change the name of the input node for the x coordinate
+ $this->button->setAttribute('name', $name.'.x');
+ $this->set(new Field\InputFormField($document->importNode($this->button, true)));
+
+ // temporarily change the name of the input node for the y coordinate
+ $this->button->setAttribute('name', $name.'.y');
+ $this->set(new Field\InputFormField($document->importNode($this->button, true)));
+
+ // restore the original name of the input node
+ $this->button->setAttribute('name', $name);
+ }
+ else {
+ $this->set(new Field\InputFormField($document->importNode($this->button, true)));
+ }
}
// find form elements corresponding to the current form
diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
index 843313c4a7e7c..19aab257485bd 100644
--- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php
+++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php
@@ -223,6 +223,11 @@ public function provideInitializeValues()
',
array('foobar' => array('InputFormField', 'foobar')),
),
+ array(
+ 'turns an image input into x and y fields',
+ '',
+ array('bar.x' => array('InputFormField', '0'), 'bar.y' => array('InputFormField', '0')),
+ ),
array(
'returns textareas',
'