How can I make my html Button
(like <button type="button" class="btn btn-warning btn-xs">delete</button>
)
call a Controller Action like deleteAction($project)
from within my twig code?(or with java script)
In twig template
<a href="{{ path('delete_route_name', {'id': entity.id }) }}">Delete</a>
On your controller
/**
* @param User $entity
*
* @Route("/{id}/entity-remove", requirements={"id" = "\d+"}, name="delete_route_name")
* @return RedirectResponse
*
*/
public function deleteActionName(User $entity)
...
see http://symfony.com/doc/current/book/templating.html#linking-to-pages
<a href="{{ path('deleteRouteName') }}">Home</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With