问题
I've created a simple contact form within the page controller. For the front-end view of this contact form, I wish to use a customised FormField_Holder
rather than the default one.
I've created a FormField_Holder.ss within themes/templates/Includes. How do I apply this template to my $ContactForm
?
I've tried this already:
public function ContactForm() {
$form = Form::create(
...
);
foreach($form->Fields() as $field) {
$field->setFieldHolderTemplate('myHolder');
}
return $form;
}
回答1:
I relocated the custom form template from
themes/mytheme/templates/Includes/
to
themes/mytheme/templates/forms/
..and it works now.
Edit: The official documentation mentions the following folder for form templates: mysite/templates/Includes but this oddly doesn't work oddly.
https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates
来源:https://stackoverflow.com/questions/38412103/silverstripe-custom-formfield-holder