Skip to content

Commit

Permalink
Merge pull request #9049 from mikedehaan/GRAILSPLUGINS-2998
Browse files Browse the repository at this point in the history
GRAILSPLUGINS-2998 Allow ID in form tag
  • Loading branch information
graemerocher committed Jun 24, 2015
2 parents b0ac122 + 66ef79e commit 1d32278
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ class FormTagLib implements ApplicationContextAware, InitializingBean {
* @attr name A value to use for both the name and id attribute of the form tag
* @attr useToken Set whether to send a token in the request to handle duplicate form submissions. See Handling Duplicate Form Submissions
* @attr method the form method to use, either 'POST' or 'GET'; defaults to 'POST'
* @attr elementId DOM element id
*/
Closure form = { attrs, body ->

Expand All @@ -374,7 +375,8 @@ class FormTagLib implements ApplicationContextAware, InitializingBean {
}

def writer = getOut()

def elementId = attrs.remove('elementId')

def linkAttrs = attrs.subMap(LinkGenerator.LINK_ATTRIBUTES)

writer << "<form action=\""
Expand Down Expand Up @@ -412,6 +414,10 @@ class FormTagLib implements ApplicationContextAware, InitializingBean {
// process remaining attributes
if (attrs.id == null) attrs.remove('id')

if (elementId) {
writer << " id=\"${elementId}\""
}

outputAttributes(attrs, writer, true)

writer << ">"
Expand Down

0 comments on commit 1d32278

Please sign in to comment.