Skip to content

Commit

Permalink
feedback #551
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaugherty committed Dec 1, 2024
1 parent 8a878bd commit cb41f21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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="'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
Expand All @@ -294,23 +299,28 @@ 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>'
}

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" />'
}

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" />'
Expand All @@ -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" />'
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit cb41f21

Please sign in to comment.