mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.3' into 4.4
This commit is contained in:
commit
8219491705
@ -184,15 +184,20 @@ class FormAction extends FormField
|
|||||||
|
|
||||||
public function getAttributes()
|
public function getAttributes()
|
||||||
{
|
{
|
||||||
return array_merge(
|
$attributes = array_merge(
|
||||||
parent::getAttributes(),
|
parent::getAttributes(),
|
||||||
array(
|
[
|
||||||
'disabled' => ($this->isReadonly() || $this->isDisabled()),
|
'disabled' => ($this->isReadonly() || $this->isDisabled()),
|
||||||
'value' => $this->Title(),
|
'value' => $this->Title(),
|
||||||
'type' => $this->getInputType(),
|
'type' => $this->getInputType(),
|
||||||
'title' => ($this->useButtonTag) ? $this->description : null,
|
]
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Override title with description if supplied
|
||||||
|
if ($this->getDescription()) {
|
||||||
|
$attributes['title'] = $this->getDescription();
|
||||||
|
}
|
||||||
|
return $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,4 +16,17 @@ class FormActionTest extends SapphireTest
|
|||||||
$formAction->setAttribute('src', 'file.png');
|
$formAction->setAttribute('src', 'file.png');
|
||||||
$this->assertContains('type="image"', $formAction->getAttributesHTML());
|
$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'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user