symfony2 - symfony 2 sending an object from a template to a controller -
symfony2 - symfony 2 sending an object from a template to a controller -
i need send object template controller. in case want send product object. possible send object argument in path ?
{% product in products %} <p>{{ product.name }} price: {{ product.price}} <a href="{{ path('shopmyshopbundle_addproduct') }}">add product</a></p> {% endfor %}
you can use:
{% product in products %} <p>{{ product.name }} price: {{ product.price}} <a href="{{ path('shopmyshopbundle_addproduct', {id : product.id}) }}">add product</a></p> {% endfor %}
but improve way using html form:
<form action="{{ path('shopmyshopbundle_addproduct') }}" method="post" {{ form_enctype(form) }}> {# hidden fields #} {{ form_widget(form) }} <input type="submit" value="add product" /> </form>
symfony2
Comments
Post a Comment