Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX: Fix correct input type for ImageFormAction replaces.

ImageFormAction is deprecated, using the new API results in a submit input rather than an image input being generated. Added hasAttribute helper to FormField as well as test coverage.
commit 78c15ea882cd7501d146f39f4e9d169dedbd3862 1 parent ce3d48e
Will Rossiter authored chillu committed
View
5 forms/FormAction.php
@@ -80,12 +80,15 @@ public function Type() {
}
function getAttributes() {
+ $type = (isset($this->attributes['src'])) ? 'image' : 'submit';
+ $type = ($this->useButtonTag) ? null : $type;
+
return array_merge(
parent::getAttributes(),
array(
'disabled' => ($this->isReadonly() || $this->isDisabled()),
'value' => $this->Title(),
- 'type' => ($this->useButtonTag) ? null : 'submit',
+ 'type' => $type,
'title' => ($this->useButtonTag) ? $this->description : null,
)
);
View
2  forms/FormField.php
@@ -357,7 +357,7 @@ function getAttribute($name) {
$attrs = $this->getAttributes();
return @$attrs[$name];
}
-
+
/**
* @return array
*/
View
16 tests/forms/FormActionTest.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * @package framework
+ * @subpackage tests
+ */
+class FormActionTest extends SapphireTest {
+
+ public function testGetField() {
+ $formAction = new FormAction('test');
+ $this->assertContains('type="submit"', $formAction->getAttributesHTML());
+
+ $formAction->setAttribute('src', 'file.png');
+ $this->assertContains('type="image"', $formAction->getAttributesHTML());
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.