每个 Grails 控制器都有多个按钮
我想做类似下图的操作:
每次我单击“添加”时,都会显示一个新页面,并且我选择要添加的按钮的名称。单击每个按钮时,应将不同的参数传递给同一控制器(每个按钮相同的控制器,不同的是参数列表)。按钮名称应该来自我的数据库。我的问题是有一个每个标签,里面有按钮。
我需要一些帮助来解决这个问题。我可以在每个标签中使用此代码:
<g:form action="removeFavourite">
<g:submitButton name="add" value="Action 1" class="button small red"/><br><br>
</g:form>
a)我不知道如何在 g:submitButton 中传递参数,如果可能的话也不知道
b)有更好的方法来做我假装的事情吗?
c)我的主要问题是像这样使用这段代码,并且仍然将参数传递给控制器。如果可以的话,请告诉我如何做,因为这样我的问题就解决了:p
提前致谢, VA
I want to do something like the folowing image:
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 help 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于表单中存在的表单元素,参数将在控制器中可用。
在您的情况下,您可能希望在表单中使用隐藏的
:
在控制器中,您将能够使用
params.id
。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:In your controller, you'll be able to use
params.id
.