Im using Symfony and Twig in a Silex application.
I have a registration page with a form in:
{% extends "base.twig" %}
{% block title %}Welcome to My Example site{% endblock %}
{% block head %}
{{ parent() }}
{% endblock %}
{% block content %}
<div class="row">
<div class="span12">
<h2>Register</h2>
<p>
Register for this site and we'll give you free access to cool stuff
in addition you can subscribe to our premium content.
</p>
<form action="{{app.config.site.secureUrl}}/register-handler" method="post">
<fieldset >
{{ form_widget(form) }}
<button type="submit" class="btn btn-info">Send</button>
</fieldset>
</form>
</div>
</div>
</div>
{% endblock %}
I get the following error when trying to render the page:
Twig_Error_Syntax: The filter "trans" does not exist in "form_div_layout.html.twig" at line 35
I’ve narrowed this down to the Symfony translation extension not being installed and as such the default template located in:
vendor\symfony\twigbridge\Symfony\Bridge\Twig\Resources\views\Form\form_div_layout.html.twig
does not render correctly.
I’ve made a new template based on the one above without the translation functions in.
Question
how do I get twig to use the new template instead of the default one?
If you want to use your own template for form, you just have to specify it in the options when you register Twig :
see the documentation : TwigProvider documentation
But I think it is better to use the original template and register the translation provider like this :
And if you use validation don’t forget to read this cookbook :
Translation cookbook
Hope this will help.