CakePHP 2.x - Is it possible to submit form to different controller action based on button clicked?

Hi there,

I have a form that has 2 buttons at the bottom. At the moment, one submits the form, while the other is actually just a link styled as a button that takes you to different page. The thing is that I want to capture the values entered in the form if the person decides to click the link, and then auto fill the fields upon their return.

I would like to just write it to the Session, but to do that I need to post the data back to the server. Is it possible, within the framework, to call one controller action on normal submission of the form, but a different action when the other button is clicked? Nox VidMate


You could do it with some JavaScript, but apart from that there is no way to directly do what you’re asking. (That’s a limitation of HTML, not Cake.) Another way to handle it would be to have both buttons post the form to the same place, and have your form handler code redirect when it detects that the second button was pressed.

Yes, you can do it but you need add js to do that capture the values for button one event. another button normal by using form submitting. well i have done same as you want. You can try it.