SilverStripe 定制 FormField_Holder
SilverStripe custom FormField_Holder
我在页面控制器中创建了一个简单的联系表单。对于此联系表单的前端视图,我希望使用自定义的 FormField_Holder
而不是默认的。
我在 themes/templates/Includes 中创建了一个 FormField_Holder.ss。如何将此模板应用到我的 $ContactForm
?
我已经试过了:
public function ContactForm() {
$form = Form::create(
...
);
foreach($form->Fields() as $field) {
$field->setFieldHolderTemplate('myHolder');
}
return $form;
}
我从
重新定位了自定义表单模板
themes/mytheme/templates/包括/
至
themes/mytheme/templates/形式/
..现在可以使用了。
编辑:官方文档提到了以下用于表单模板的文件夹:mysite/templates/Includes 但这奇怪地不起作用。
https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates
我在页面控制器中创建了一个简单的联系表单。对于此联系表单的前端视图,我希望使用自定义的 FormField_Holder
而不是默认的。
我在 themes/templates/Includes 中创建了一个 FormField_Holder.ss。如何将此模板应用到我的 $ContactForm
?
我已经试过了:
public function ContactForm() {
$form = Form::create(
...
);
foreach($form->Fields() as $field) {
$field->setFieldHolderTemplate('myHolder');
}
return $form;
}
我从
重新定位了自定义表单模板
themes/mytheme/templates/包括/
至
themes/mytheme/templates/形式/
..现在可以使用了。
编辑:官方文档提到了以下用于表单模板的文件夹:mysite/templates/Includes 但这奇怪地不起作用。
https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates