Witam,
Mam problem z następującą iteracją w szablonie TWIG:
<http://december.com/html/4/element/form.html action="{{ path('meet_create') }}" method="post" {{ form_enctype(form) }}> {% for i in 1..20 %} {{ form_widget(form.position.vars.prototype) }} {% endfor %} <http://december.com/html/4/element/p.html> <http://december.com/html/4/element/button.html type="submit">Create</http://december.com/html/4/element/button.html> </http://december.com/html/4/element/p.html> </http://december.com/html/4/element/form.html>
Można za pomocą javascriptu "skopiować" widget i umieścić go na stronie wielokrotnie, ale to złe rozwiązanie każdy taki widget ma ten sam identyfikator.
Zgaduje że najlepszym rozwiązaniem będzie http://symfony.com/doc/current/reference/forms/types/collection.html.
Udało mi się zrobić coś takiego:
{% for i in 1..20 %}
{{ form_widget(form.position.vars.prototype)|replace({ __name__:i }) }}
{% endfor %}
ale niestety zamiast przycisku Input wyświetla mi się taki kod html:
<input type="text" id="my_costambundle_meettype_position_1" name="my_costambundle_meettype[position][1]" required="required" />
co robię źle ?
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)