3
votes

I'm very new to Silverstripe,

On the CMS page I can add a dropdown form item, and I see that I can create options. BUT. What I want to do is populate the dropdown from an array. How can I do this?

The array will look something like this:

$dropdownFields = array(
  'option1' => array(lots of emails),
  'option2' => array(lots of emails),
  'option3' => array(lots of emails),
  etc
)

I think what I want to do is have a DataObject with an 'option' field and a 'text' field where emails are entered in CSV format.

But how can I get the dropdown menu UserForms to retrieve option values from the DataObject instead of as an input from a user via the cms...

1
Just to be clear, you want to add a drop down field to a UserDefinedForm page and have the options populated by a specific DataObject. Is that correct? We will need to create a custom form field to achieve this. - 3dgoo

1 Answers

2
votes

You cannot achieve this via the CMS and the module alone. You will need to create a custom EditableFormField to achieve this.

Subclass this and make changes where necessary: https://github.com/silverstripe/silverstripe-userforms/blob/master/code/model/formfields/EditableDropdown.php