Merge branch '4.3' into 4.4

This commit is contained in:
Serge Latyntcev 2019-11-20 11:08:35 +13:00
commit 8219491705
2 changed files with 24 additions and 6 deletions

View File

@ -184,15 +184,20 @@ class FormAction extends FormField
public function getAttributes()
{
return array_merge(
$attributes = array_merge(
parent::getAttributes(),
array(
[
'disabled' => ($this->isReadonly() || $this->isDisabled()),
'value' => $this->Title(),
'type' => $this->getInputType(),
'title' => ($this->useButtonTag) ? $this->description : null,
)
'value' => $this->Title(),
'type' => $this->getInputType(),
]
);
// Override title with description if supplied
if ($this->getDescription()) {
$attributes['title'] = $this->getDescription();
}
return $attributes;
}
/**

View File

@ -16,4 +16,17 @@ class FormActionTest extends SapphireTest
$formAction->setAttribute('src', 'file.png');
$this->assertContains('type="image"', $formAction->getAttributesHTML());
}
public function testGetTitle()
{
// Test that description overrides title attribute, but doesn't prevent it from
// working if blank.
$action = new FormAction('test');
$action->setAttribute('title', 'this is the title');
$this->assertEquals('this is the title', $action->getAttribute('title'));
$action->setDescription('this is a better title');
$this->assertEquals('this is a better title', $action->getAttribute('title'));
$action->setDescription(null);
$this->assertEquals('this is the title', $action->getAttribute('title'));
}
}