mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2718 from silverstripe-rebelalliance/2503
BUG: Fixes performReadonlyTransformation for OptionSetField Closes #2503
This commit is contained in:
commit
5beaebc43a
@ -93,7 +93,7 @@ class OptionsetField extends DropdownField {
|
||||
public function performReadonlyTransformation() {
|
||||
// Source and values are DataObject sets.
|
||||
$field = $this->castedCopy('LookupField');
|
||||
$field->setValue($this->getSource());
|
||||
$field->setSource($this->getSource());
|
||||
$field->setReadonly(true);
|
||||
|
||||
return $field;
|
||||
|
@ -24,4 +24,14 @@ class OptionsetFieldTest extends SapphireTest {
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
public function testReadonlyField() {
|
||||
$sourceArray = array(0 => 'No', 1 => 'Yes');
|
||||
$field = new OptionsetField('FeelingOk', 'are you feeling ok?', $sourceArray, 1);
|
||||
$field->setEmptyString('(Select one)');
|
||||
$field->setValue(1);
|
||||
$readonlyField = $field->performReadonlyTransformation();
|
||||
preg_match('/Yes/', $field->Field(), $matches);
|
||||
$this->assertEquals($matches[0], 'Yes');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user