When I create a new form field and use setTemplate() SilverStripe/Apache crashes
I have played around with all sorts of locations for my custom FormField_holder template and backslashes/forward slash in the path. But, if SS cannot find my template the field is rendered with the default and if it can find it SS crashes. I have also had SS throw an error that it cannot stat the template, but I cannot seem to reproduce this at time of writing.
Here is the code I am using to create the Form object.
$fields = FieldList::create( TextField::create('Name','Name') ->setTemplate('Forms\\FormField_holder') // crashes site!! ,EmailField::create('Email','Email') ->setTemplate('Forms\\FormField_holder') // crashes site!! ,TextareaField::create('Message','How can we help you?') ); $actions = FieldList::create( FormAction::create('submit','Send Message') ); $required = RequiredFields::create( 'Name', 'Email', 'Message' ); $form = Form::create( $this, __FUNCTION__, $fields, $actions, $required );
And the contents of app\templates\Forms\FormField_holder.ss
<div class="field<% if $extraClass %> $extraClass<% end_if %>"> <% if $Title %><label for="$ID">$Title</label><% end_if %> $Field </div>
This is driving me up the wall, so I really hope someone can point me in the right direction!