Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 994
Zach Smith Avatar asked Mar 18 '26 20:03

Zach Smith


1 Answers

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

like image 61
user4977453 Avatar answered Mar 20 '26 11:03

user4977453



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!