mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: Ensure extra classes are copied over to readonly/disabled fields
This commit is contained in:
parent
465ca1d16d
commit
cb37e5fb87
@ -1355,13 +1355,14 @@ class FormField extends RequestHandler
|
||||
$field = $classOrCopy::create($this->name);
|
||||
}
|
||||
|
||||
$extraClasses = $this->extraClasses ? array_values($this->extraClasses) : [];
|
||||
$field
|
||||
->setValue($this->value)
|
||||
->setForm($this->form)
|
||||
->setTitle($this->Title())
|
||||
->setLeftTitle($this->LeftTitle())
|
||||
->setRightTitle($this->RightTitle())
|
||||
->addExtraClass($this->extraClass) // Don't use extraClass(), since this merges calculated values
|
||||
->addExtraClass(implode(' ', $extraClasses)) // Don't use extraClass(), since this merges calculated values
|
||||
->setDescription($this->getDescription());
|
||||
|
||||
// Only include built-in attributes, ignore anything set through getAttributes().
|
||||
|
@ -259,6 +259,14 @@ class FormFieldTest extends SapphireTest
|
||||
$this->assertStringNotContainsString('readonly="readonly"', $field->getAttributesHTML());
|
||||
}
|
||||
|
||||
public function testReadonlyPreservesExtraClass()
|
||||
{
|
||||
$field = new FormField('MyField');
|
||||
$field->addExtraClass('myextraclass1')->addExtraClass('myextraclass2');
|
||||
$field->setReadonly(true);
|
||||
$this->assertStringContainsString('myextraclass1 myextraclass2', $field->getAttributesHTML());
|
||||
}
|
||||
|
||||
public function testDisabled()
|
||||
{
|
||||
$field = new FormField('MyField');
|
||||
|
Loading…
Reference in New Issue
Block a user