diff --git a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy index 7c238ab9c9..b2f6b2c659 100644 --- a/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy +++ b/grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/taglib/FormTagLib.groovy @@ -524,7 +524,7 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar @Deprecated(since = '7.0.0') Closure actionSubmit = { attrs -> if (!attrs.value) { - throwTagError("Tag [actionSubmit] is missing required attribute [value]") + throwTagError('Tag [actionSubmit] is missing required attribute [value]') } attrs.tagName = "actionSubmit" @@ -578,13 +578,14 @@ class FormTagLib implements ApplicationContextAware, InitializingBean, TagLibrar */ def formActionSubmit = { Map attrs -> if (!attrs.value) { - throwTagError("Tag [formActionSubmit] is missing required attribute [value]") + throwTagError('Tag [formActionSubmit] is missing required attribute [value]') } def elementId = attrs.remove('id') - // Reserved - attrs.remove('type') // forced to a submit because of this tag type + // the following attributes are reserved because this tag must be of type `submit` and the `formaction` attr + // will be generated by the link attributes. + attrs.remove('type') attrs.remove('formAction') out << '<input type="submit" formaction="' diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormTagLibTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormTagLibTests.groovy index 0e709bf9f6..b798fecee9 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormTagLibTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormTagLibTests.groovy @@ -285,7 +285,12 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormWithURL() { when: unRegisterRequestDataValueProcessor() - String output = tagLib.form(new TreeMap([url:[controller:'con', action:'action'], id: 'formElementId'])) + String output = tagLib.form( + new TreeMap([ + url: [controller: 'con', action: 'action'], + id: 'formElementId' + ]) + ) then: output == '<form action="/con/action" method="post" id="formElementId" ></form>' @@ -294,7 +299,12 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormWithURLAndRequestDataValueProcessor() { when: - String output = tagLib.form(new TreeMap([url:[controller:'con', action:'action'], id: 'formElementId'])) + String output = tagLib.form( + new TreeMap([ + url: [controller: 'con', action: 'action'], + id: 'formElementId' + ]) + ) then: output == '<form action="/con/action" method="post" id="formElementId" ><input type="hidden" name="requestDataValueProcessorHiddenName" value="hiddenValue" />\n</form>' @@ -302,7 +312,7 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormActionSubmitWithController() { when: - String output = tagLib.formActionSubmit([controller:'con', id: 'formElementId', value: 'Submit']) + String output = tagLib.formActionSubmit([controller: 'con', id: 'formElementId', value: 'Submit']) then: output == '<input type="submit" formaction="/con" value="Submit" id="formElementId" />' @@ -310,7 +320,7 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormActionSubmitWithControllerAndAction() { when: - String output = tagLib.formActionSubmit([controller:'con', action: 'act', id: 'formElementId', value: 'Submit']) + String output = tagLib.formActionSubmit([controller: 'con', action: 'act', id: 'formElementId', value: 'Submit']) then: output == '<input type="submit" formaction="/con/act" value="Submit" id="formElementId" />' @@ -319,7 +329,7 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormActionSubmitWithURLAndNoParams() { when: unRegisterRequestDataValueProcessor() - String output = tagLib.formActionSubmit(new TreeMap([url:[controller:'con', action:'action'], id: 'formElementId', value: 'Submit'])) + String output = tagLib.formActionSubmit(new TreeMap([url: [controller: 'con', action:'action'], id: 'formElementId', value: 'Submit'])) then: output == '<input type="submit" formaction="/con/action" id="formElementId" value="Submit" />' @@ -328,12 +338,17 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib def testFormActionSubmitWithAURLAndRequestDataValueProcessor() { when: String output = tagLib.formActionSubmit( - new TreeMap( - [ - url:[controller:'con', action:'action', params: [requestDataValueProcessorParamName: 'paramValue']], - id: 'formElementId', value: 'My Button' + new TreeMap([ + url: [ + controller: 'con', + action:'action', + params: [ + requestDataValueProcessorParamName: 'paramValue' ] - ) + ], + id: 'formElementId', + value: 'My Button' + ]) ) then: @@ -346,12 +361,17 @@ class FormTagLibTests extends Specification implements TagLibUnitTest<FormTagLib when: String output = tagLib.formActionSubmit( - new TreeMap( - [ - url:[controller:'con', action:'action', params: [requestDataValueProcessorParamName: 'paramValue']], - id: 'formElementId', value: 'My Button' - ] - ) + new TreeMap([ + url: [ + controller: 'con', + action:'action', + params: [ + requestDataValueProcessorParamName: 'paramValue' + ] + ], + id: 'formElementId', + value: 'My Button' + ]) ) then: