title: Symfony 2 custom form field type: how to add javascript and css only once?
body: <p>I want to use javascript in custom Symfony 2 form field type extension. So, I have Twig extension template like this:</p>
  
  <pre><code>{% block some_widget %}
      &lt;input ... /&gt;
  
      &lt;script src="some.js"&gt;&lt;/script&gt;
      &lt;link href="some.css" /&gt;
  {% endblock %}
  </code></pre>
  
  <p>But I want to have these script and link tags only once in my HTML, ideally in head tag, without modifing base template. I tried to extend Twig blocks, but I have no access to action template blocks inside form template. Or maybe something like this:</p>
  
  <pre><code>{# widget tempate #}
  {% block some_widget %}
      &lt;input ... /&gt;
  
      {{ use_javascript('some.js') }}
      {{ use_css('some.css') }}
  {% endblock %}
  
  {# main action template #}
  ...
  &lt;head&gt;
  {{ dump_javascripts() }}
  {{ dump_css() }}
  &lt;/head&gt;
  ...
  </code></pre>
  
  <p>How to do this with Symfony 2 Forms + Twig?</p>
  
  <p>P.S. Sorry for my bad english.</p>