Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding custom settings to userforms module - Only saves the first?


Go to End


1206 Views

Avatar
Peavers

Community Member, 20 Posts

6 March 2015 at 3:59pm

I'm adding a custom drop down to the userform module and everything seemed to work, however:

If I set the following:
Textfield One - Dropdown option one
Textfield Two - Dropdown option two

It seems to only save the the setting under Textfield One, and ignores Textfield Two. If I then go back and set Textfield Two again, it wipes out Textfield One.

Am I supposed to iterate over something save each value independently or ...?

//config.yml
EditableFormField:
  extensions:
    - CustomEditableFormField

//CustomEditableFormField.php 
class CustomEditableFormField extends DataExtension
{
    public function updateFieldConfiguration(FieldList $fields)
    {
        $fields->push(DropdownField::create($this->owner->getSettingName('CustomTextId'), 'Custom field')
            ->setSource(array("1" => "One", "2" => "Two"))
            ->setEmptyString($this->owner->getSetting('CustomTextId')));
    }