form
目的 Purpose
Creates a form that submits to a controller, action, and/or id. Beyond what is described below, all the usual HTML attributes apply.使用例 Examples
Example controller for an application called "shop":class Book {
def list() {
[books: Book.list(params)]
} def show() {
[book: Book.get(params.id)]
}
}<g:form name="myForm" action="myaction" id="1">...</g:form> results in: <form action="/shop/book/myaction/1" method="post" name="myForm" id="myForm"> … </form><g:form name="myForm" url="[action:'list',controller:'book']">...</g:form> results in: <form action="/shop/book/list" method="post" name="myForm" id="myForm"> … </form><g:form action="show">...</g:form> results in: <form action="/shop/book/show" method="post" >...</form>
詳細 Description
属性 Attributes
action(optional) - The name of the action to use in the link; if not specified the default action will be linkedcontroller(optional) - The name of the controller to use in the link; if not specified the current controller will be linkedid(optional) - The id to use in the linkfragment(optional) - The link fragment (often called anchor tag) to usemapping(optional) - The named URL mapping to use to rewrite the linkparams(optional) - A Map of request parametersurl(optional) - A map containing the action,controller,id etc.absolute(optional) - Iftruewill prefix the link target address with the value of thegrails.serverURLproperty fromConfig.groovy, or http://localhost:<port> if there is no setting inConfig.groovyand not running in production.base(optional) - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of theabsoluteproperty, if both are specified.name(optional) - A value to use for both the name and id attribute of the form taguseToken(optional) - Set whether to send a token in the request to handle duplicate form submissions. See Handling Duplicate Form Submissions

