Merge pull request #4717 from chillu/pulls/3.2/fix-inlineformaction

BUG Fix broken InlineFormAction
This commit is contained in:
Damian Mooyman 2015-10-29 11:11:36 +13:00
commit 1303fc5ff3
2 changed files with 21 additions and 2 deletions

View File

@ -20,7 +20,7 @@ class InlineFormAction extends FormField {
*/
public function __construct($action, $title = "", $extraClass = '') {
$this->extraClass = ' '.$extraClass;
parent::__construct($action, $title, null, null);
parent::__construct($action, $title);
}
public function performReadonlyTransformation() {
@ -39,7 +39,8 @@ class InlineFormAction extends FormField {
return DBField::create_field(
'HTMLText',
FormField::create('input', array(
FormField::create_tag('input', array(
'type' => 'submit',
'name' => sprintf('action_%s', $this->getName()),
'value' => $this->title,
'id' => $this->ID(),

View File

@ -0,0 +1,18 @@
<?php
/**
* Tests {@see InlineFormAction}
*/
class InlineFormActionTest extends SapphireTest {
public function testField() {
$action = new InlineFormAction('dothing', 'My Title', 'ss-action');
$html = (string)$action->Field();
$this->assertContains('<input', $html);
$this->assertContains('type="submit"', $html);
$this->assertContains('name="action_dothing"', $html);
$this->assertContains('value="My Title"', $html);
$this->assertContains('id="dothing"', $html);
$this->assertContains('class="action ss-action"', $html);
}
}