开发者

Grails controllers each with multiple buttons

I want to do something like the folowing image:

Grails controllers each with multiple buttons

Everytime i click on Add, a new page is shown and i chose the name for a button to add. Every button, when is clicked, should pass a diferent params to the same controller (same controller for each button, what differs is the params list). The button name should come from my database. My problem is about having an each tag with the buttons inside.

I need help some h开发者_运维百科elp with this. I could use this code inside my each tag:

<g:form action="removeFavourite">
                  <g:submitButton name="add" value="Action 1" class="button small red"/><br><br>
                          </g:form>

a) I dont know how to pass params in the g:submitButton, neither if it is possible

b) Any better way of doing what i pretend ?

c) My main problem is using this code like this and still pass params to the controller. If it is possible to do, tell me how because then my question is solved :p

Thanks in advanced, VA


Params will be available in the controller for form elements that are present in the form.

In your case, you probably want to use a hidden <input> within the form:

<g:form action="removeFavourite">
    <g:hiddenField name="id" value="${favourite.id}"/>
    <g:submitButton name="add" value="Action 1" .../>
</g:form>

In your controller, you'll be able to use params.id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜