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

Closed
webtorque7 opened this Issue Oct 7, 2013 · 1 comment

Comments

Projects
None yet
2 participants

OptionsetField->performReadonlyTransformation uses setValue instead of setSource

Contributor

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

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

}

class OptionSetTestPage_Controller extends Page_Controller {
        static $allowed_actions = array(
                'Form'
        );

        // 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(
                        $option,
                        $dropdown,
                        $textField
                );

                $actions = new FieldList(
                        FormAction::create('subscribe')->setTitle('Submit')
                );

                $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';
                Debug::Dump($data);
        }

}

** Results **
// using setValue

Option Set Field
(none)
Dropdown Fields
Two
Text Field
TextField

// using setSource
Option Set Field
Two
Dropdown Fields
Two
Text Field
TextField

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