Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get name of clicked submit button in grails

Tags:

grails

On a form I have two submit buttons:

<g:submitButton name="add" value="Add"/>
<g:submitButton name="addAnother" value="Add and Create Another"/>

I need to take slightly different action based on which button was used to submit the form. How to I get the name of the clicked button in my controller?

like image 793
speshak Avatar asked Apr 29 '10 20:04

speshak


1 Answers

The name of the clicked button ends up in params:

if(params["addAnother"])
   doThis()
else
   doThat()
like image 181
speshak Avatar answered Oct 05 '22 23:10

speshak