Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

BUG: OptionsetField performReadonlyTransformation is uses LookupField incorrectly #2503

Closed
webtorque7 opened this Issue · 1 comment

2 participants

@webtorque7

OptionsetField->performReadonlyTransformation uses setValue instead of setSource

@kmayo-ss

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 kmayo-ss referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kmayo-ss kmayo-ss referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kmayo-ss kmayo-ss referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kmayo-ss kmayo-ss referenced this issue from a commit in silverstripe-rebelalliance/sapphire
@kmayo-ss kmayo-ss 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
44a8537
@kinglozzer kinglozzer referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.