Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

BUG: OptionsetField performReadonlyTransformation is uses LookupField incorrectly #2503

webtorque7 opened this Issue Oct 7, 2013 · 1 comment


None yet
2 participants

OptionsetField->performReadonlyTransformation uses setValue instead of setSource


kmayo-ss commented Dec 11, 2013

Does seem to be broken created a basic form (see below) and the OptionSet is empty when using setValue but SetSource does set the value see results right at the bottom

class OptionSetTestPage extends Page {
        static $db = array(
                'PageOptions' => "Enum('One, Two, Three')"


class OptionSetTestPage_Controller extends Page_Controller {
        static $allowed_actions = array(

        // Newsletter form for subscribing to mailing lists
        public function Form() {
                $option = new OptionSetField('PageOptions', 'Option Set Field', singleton('OptionSetTestPage')->dbObject('PageOptions')->enumValues(), 'Two');
                $option = $option->performReadonlyTransformation();
                $dropdown = new DropdownField('DropdownOptions', 'Dropdown Fields', singleton('OptionSetTestPage')->dbObject('PageOptions')->enumValues(), 'Two');
                $dropdown = $dropdown->performReadonlyTransformation();
                $textField = new TextField('TextField', 'Text Field','TextField');
                $textField = $textField->performReadonlyTransformation();
                $fields = new FieldList(

                $actions = new FieldList(

                $required = new RequiredFields(array('PageOptions'));

                $form = new Form($this, 'Form', $fields, $actions, $required);
                return $form;

        // handle the newsletter form being posted which calls addUserToList if successful
        public function subscribe($data, $form) {
                echo 'Form Submitted';


** Results **
// using setValue

Option Set Field
Dropdown Fields
Text Field

// using setSource
Option Set Field
Dropdown Fields
Text Field

kmayo-ss added a commit to silverstripe-terraformers/silverstripe-framework that referenced this issue Jan 30, 2014

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment