////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////


==== Form Basics


GSP supports many different tags for working with HTML forms and fields, the most basic of which is the link:{gspTagsRef}form.html[form] tag. This is a controller/action aware version of the regular HTML form tag. The `url` attribute lets you specify which controller and action to map to:

[source,xml]
----
<g:form name="myForm" url="[controller:'book',action:'list']">...</g:form>
----

In this case we create a form called `myForm` that submits to the ``BookController``'s `list` action. Beyond that, all the usual HTML attributes apply.


==== Form Fields


In addition to easy construction of forms, GSP supports custom tags for dealing with different types of fields, including:

* link:{gspTagsRef}textField.html[textField] - For input fields of type 'text'
* link:{gspTagsRef}passwordField.html[passwordField] - For input fields of type 'password'
* link:{gspTagsRef}checkBox.html[checkBox] - For input fields of type 'checkbox'
* link:{gspTagsRef}radio.html[radio] - For input fields of type 'radio'
* link:{gspTagsRef}hiddenField.html[hiddenField] - For input fields of type 'hidden'
* link:{gspTagsRef}select.html[select] - For dealing with HTML select boxes

Each of these allows GSP expressions for the value:

[source,xml]
----
<g:textField name="myField" value="${myValue}" />
----

GSP also contains extended helper versions of the above tags such as link:{gspTagsRef}radioGroup.html[radioGroup] (for creating groups of link:{gspTagsRef}radio.html[radio] tags), link:{gspTagsRef}localeSelect.html[localeSelect], link:{gspTagsRef}currencySelect.html[currencySelect] and link:{gspTagsRef}timeZoneSelect.html[timeZoneSelect] (for selecting locales, currencies and time zones respectively).


==== Multiple Submit Buttons


The age-old problem of dealing with multiple submit buttons is also handled elegantly with Grails using the link:{gspTagsRef}formActionSubmit.html[formActionSubmit] tag. It is just like a regular submit, but lets you specify an alternative controller & action to submit to:

[source,xml]
----
<g:formActionSubmit value="Some update label" controller="mycontroller" action="update" />
----
