Zach Smith
Zach Smith

Reputation: 8971

Silverstripe UserForms - populate options from DataObject

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...

Upvotes: 3

Views: 583

Answers (1)

user4977453
user4977453

Reputation: 96

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

Upvotes: 2

Related Questions