mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUG: #2503 Fixes performReadonlyTransformation for OptionSetField
NEW: Adding unit test for performReadonlyTransformation #nd fixing OptionSetField #2503 BUG: Fixing undefined variables and function parameters for PerformReadonlyTransformation unit tests NEW: Adding unit test to OptionsetField for read only fields
This commit is contained in:
parent
d81c3570af
commit
44a8537f68
@ -93,7 +93,7 @@ class OptionsetField extends DropdownField {
|
|||||||
public function performReadonlyTransformation() {
|
public function performReadonlyTransformation() {
|
||||||
// Source and values are DataObject sets.
|
// Source and values are DataObject sets.
|
||||||
$field = $this->castedCopy('LookupField');
|
$field = $this->castedCopy('LookupField');
|
||||||
$field->setValue($this->getSource());
|
$field->setSource($this->getSource());
|
||||||
$field->setReadonly(true);
|
$field->setReadonly(true);
|
||||||
|
|
||||||
return $field;
|
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…
x
Reference in New Issue
Block a user