Silverstripe用户表单-从数据对象填充选项


Silverstripe UserForms - populate options from DataObject

我是Silverstripe的新手,

在CMS页面上,我可以添加一个下拉表单项,我看到我可以创建选项。但是。我要做的是从数组中填充下拉列表。我该怎么做呢?

数组看起来像这样:

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

我想我要做的是有一个DataObject与'option'字段和'text'字段,其中电子邮件以CSV格式输入。

但是我怎么能得到下拉菜单UserForms检索选项值从数据对象,而不是作为一个输入从用户通过cms…

您不能单独通过CMS和模块来实现这一点。您需要创建一个自定义的EditableFormField来实现这一点。

子类化这个,并在必要时进行更改:https://github.com/silverstripe/silverstripe-userforms/blob/master/code/model/formfields/EditableDropdown.php