I've been having some trouble trying to render a form field with my own custom template. I followed the instructions provided here: https://docs.silverstripe.org/en/3.4/developer_guides/forms/form_templates/
However, when I try to set a template for a text field or for a field holder, it just uses the default templates.
This is what I've done:
$title_field = new TextField('title', 'Title*'); $title_field->setTemplate('my-text-field');
I made sure to add my templates to mysite/templates/Includes, and I even moved it around within the themes folder of our theme. However, none of that seems to work and it always ends up using the default template. Any help would be deeply appreciated.
I found the solution to my issue. From the looks of it, the file path the link tells you to store your templates in (mysite/templates/Includes/) doesn't seem to be recognized. Instead, the path has to be similar to how the default templates are saved in the framework. For example, the form templates I made had to be saved under mysite/templates/forms/ in order to be recognized by SilverStripe. Not sure if this is an issue or if the documentation isn't updated, but this is what I did to get my templates to render.