SilverStripe custom FormField_Holder

Deadly 提交于 2020-01-05 03:52:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!