Silverstripe Version: CMS 4.1.0
Question: How to implement/create a simple select dropdown
Hi there. Very new to SilverStripe. Have been thrown in the deep end and don’t really know what I am doing. I am trying to create a dropdown select on a form.
public function Form(){
$fields = new FieldList(
$Store = new SelectField('Store', 'Store', array("1" => "hello", "2" => "Hello2")),
);
$actions = new FieldList(
new FormAction('submit', 'Enquire Now')
);
$requiredFields = new RequiredFields(
'Store'
);
return new Form($this, 'Form', $fields, $actions, $requiredFields);
}
The above code is throwing an error which breaks the site.
I am trying to use the documentation here
https://api.silverstripe.org/4/SilverStripe/Forms/SelectField.html
But it’s pretty confusing, and I look at it and nothing really tells me anything… and there’s no other examples or anything online!
Any help greatly appreciated.
Thanks