File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
src/grails/grails-app/taglib Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -29,27 +29,50 @@ class FormTagLib {
2929 * Creates a new text field
3030 */
3131 def textField = { attrs ->
32- attrs. type = " text"
32+ attrs. type = " text"
33+ attrs. tagName = " textField"
3334 field(attrs)
3435 }
3536 /**
3637 * Creates a hidden field
3738 */
3839 def hiddenField = { attrs ->
3940 attrs. type = " hidden"
41+ attrs. tagName = " hiddenField"
4042 field(attrs)
4143 }
4244 /**
4345 * Creates a submit button
4446 */
4547 def submitButton = { attrs ->
4648 attrs. type = " submit"
49+ attrs. tagName = " submitButton"
4750 field(attrs)
4851 }
4952 /**
5053 * A general tag for creating fields
5154 */
52- def field = { attrs ->
55+ def field = { attrs ->
56+ if (! attrs. name && ! attrs. field) {
57+ throwTagError(" Tag [$tagName ] is missing required attribute [name] or [field]" )
58+ }
59+ attrs. remove(' tagName' )
60+
61+ if (attrs. field)
62+ attrs. name = attrs. remove(' field' )
63+
64+ attrs. id = (! attrs. id ? attrs. name : attrs. id)
65+
66+ def val = attrs. remove(' bean' )
67+ if (val) {
68+ if (attrs. name. indexOf(' .' ))
69+ attrs. name. split(' \\ .' ). each { val = val?. " $it " }
70+ else {
71+ val = val[name]
72+ }
73+ attrs. value = val
74+ }
75+ attrs. value = (attrs. value ? attrs. value : " " )
5376 out << " <input type='${ attrs.remove('type')} ' "
5477 attrs. each { k ,v ->
5578 out << k << " =\" " << v << " \" "
You can’t perform that action at this time.
0 commit comments