samba
samba

Reputation: 31

How to create multiple submit buttons in gsp of groovy with grails?

I have three actions namely create, createMonthly, createQuarterly and i have only one gsp page in that i need to create three submit buttons that three buttons are data will be goto save action...

I created the buttons like this

<div class="buttons">
  <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
  <br>
  <span class="button"><g:submitButton name="createMonthly" class="save" value="${message(code: 'default.button.createMonthly.label', default: 'Create Monthly')}" /></span>
  <br>
  <span class="button"><g:submitButton name="createQuarterly" class="save" value="${message(code: 'default.button.createQuarterly.label', default: 'Create Quarterly')}" /></span>
</div>

but its not working properly in the sense when i click any button it show create action only, how to call createMonthly and createQuarterly actions from this, plz help me.....

Upvotes: 3

Views: 6041

Answers (2)

netbrain
netbrain

Reputation: 9304

As Nicolas said. use actionSubmit. Your code should look like this.

<div class="buttons">
  <span class="button"><g:actionSubmit action="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
  <br>
  <span class="button"><g:actionSubmit action="createMonthly" class="save" value="${message(code: 'default.button.createMonthly.label', default: 'Create Monthly')}" /></span>
  <br>
  <span class="button"><g:actionSubmit action="createQuarterly" class="save" value="${message(code: 'default.button.createQuarterly.label', default: 'Create Quarterly')}" /></span>
</div>

Upvotes: 1

Nicolas Modrzyk
Nicolas Modrzyk

Reputation: 14187

Use actionSubmit in your GSP.

For example:

<!--'Update' is action, label is 'Some update label'-->
<g:actionSubmit value="Some update label" action="Update" /> 

Upvotes: 7

Related Questions