jeudi 9 avril 2015

Symfony 2 Form theming and JS

I have AFormType class and corresponding twig template which is processed in some_controller_action.html.twig such way:



{% form_theme a_form with ['ABundle:Form:a-form.html.twig'] %}
{{ form(a_form) }}


I want a-form.html.twig contain javascript, which is related to the form only, and to nothing else. So I added there following:



{% block javascripts %}
<script type="text/javascript">
$(document).ready(function () {
...
}
{% endblock %}


some_controller_action.html.twig also has block javascripts, which contains document.load.


The problem: template engine ignores a_form.html.twig script and not includes to rendered page. controller's html.twig JS is processed correctly.


How may I solve the issue?


Aucun commentaire:

Enregistrer un commentaire