Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two forms - two submit buttons. How the controller identify which button was clicked?

I have two forms with two submit buttons in one page, one view and one controller should manage them. I want it to perform one action if the first one is clicked, and another action - if the second. I tried this where edit is the name of the form but it doesn't work:

if($this->getRequest()->get('edit'))

I also tried setting value to the submit buttons but I could't make it go, too. Please help me to find a way how to identify which button was pressed. :)

like image 974
Faery Avatar asked Nov 30 '22 05:11

Faery


1 Answers

Symfony 2.3 comes with the solution. It supports buttons in forms, and you have isClicked() method to check if a button was clicked.

http://symfony.com/blog/new-in-symfony-2-3-buttons-support-in-forms

like image 97
Veelkoov Avatar answered Dec 04 '22 10:12

Veelkoov