mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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.
This commit is contained in:
parent
ce3d48e310
commit
78c15ea882
@ -80,12 +80,15 @@ class FormAction extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAttributes() {
|
function getAttributes() {
|
||||||
|
$type = (isset($this->attributes['src'])) ? 'image' : 'submit';
|
||||||
|
$type = ($this->useButtonTag) ? null : $type;
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
parent::getAttributes(),
|
parent::getAttributes(),
|
||||||
array(
|
array(
|
||||||
'disabled' => ($this->isReadonly() || $this->isDisabled()),
|
'disabled' => ($this->isReadonly() || $this->isDisabled()),
|
||||||
'value' => $this->Title(),
|
'value' => $this->Title(),
|
||||||
'type' => ($this->useButtonTag) ? null : 'submit',
|
'type' => $type,
|
||||||
'title' => ($this->useButtonTag) ? $this->description : null,
|
'title' => ($this->useButtonTag) ? $this->description : null,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -357,7 +357,7 @@ class FormField extends RequestHandler {
|
|||||||
$attrs = $this->getAttributes();
|
$attrs = $this->getAttributes();
|
||||||
return @$attrs[$name];
|
return @$attrs[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
16
tests/forms/FormActionTest.php
Normal file
16
tests/forms/FormActionTest.php
Normal file
@ -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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user