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:
Will Rossiter 2012-06-13 09:57:54 +02:00 committed by Ingo Schommer
parent ce3d48e310
commit 78c15ea882
3 changed files with 21 additions and 2 deletions

View File

@ -80,12 +80,15 @@ class FormAction extends FormField {
}
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 File

@ -357,7 +357,7 @@ class FormField extends RequestHandler {
$attrs = $this->getAttributes();
return @$attrs[$name];
}
/**
* @return array
*/

View 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());
}
}