Reputation: 707
I have two independent forms that perform the same action, but one should do something more than the other. So, I need to make sure I can know in the controller which submitButton
called that action in order to process the diferent requests. So my question is:
In a form, with two
<g:submitButton name="search" value="More Results"/>
<g:submitButton name="searchAndMore" value="More Results"/>
Is there any way to know which one called the action?
Upvotes: 1
Views: 1934
Reputation: 120286
In your controller, your submit button will be present as a request parameter with the same name and value as the button in the markup:
params.search == "More Results"
or
params.searchAndMore == "More Results"
You could also check using:
if (params.containsKey('search'))
// or
if (params.search)
Upvotes: 1
Reputation: 1043
May be helpful :
<g:form>
...
<g:actionSubmit action="search" value="Search"/>
<g:actionSubmit action="searchAndMore" value="More Results"/>
</g:form>
Upvotes: 1