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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -