0

I need to fetch the CSRF token of my Symfony2 form in my $scope.formData var, to do this I tried to use a ng-model directive but it doesn't work on an hidden field. So i read here that I'd better use the ng-value directive.

So I wrote this twig form theme to rewrite the "hidden" type field:

{% block hidden_widget %}
    {% spaceless %}
        {% set type = type|default('hidden') %}
         <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %} value="{{ value }}" ng-value="{{ full_name }}" {% endif %}/>
    {% endspaceless %}
{% endblock %}

It produces this HTML:

<input type="hidden" ng-model="data['createpv[_token]']" id="createpv__token" name="createpv[_token]" ng-value="createpv[_token]" class="ng-pristine ng-valid">

Why is'nt the value attribute printed ? It seems to be a conflict with ng-value but why ? How can I avoid this ?

Community
  • 1
  • 1
RChanaud
  • 194
  • 2
  • 12

0 Answers0