KickstartWithBootstrap icon indicating copy to clipboard operation
KickstartWithBootstrap copied to clipboard

Type of g:field tag

Open claudiogg88 opened this issue 10 years ago • 9 comments

i'm have a field in my domain class with double type, when I run generate-all in my domain class the _form template generated have a g:field tag in this field without "type" attributte

Domain class: Double importe _form.gsp : <g:field class="form-control" name="importe" value="${fieldValue(bean: facturaItemInstance, field: 'importe')}" required="" />

claudiogg88 avatar Apr 08 '14 16:04 claudiogg88

Maybe it should be type="number" and add step="any" to allow chrome to input float numbers. Ref: http://stackoverflow.com/questions/8052962/groovy-grails-float-value-and-html5-number-input

magicboo avatar Apr 08 '14 17:04 magicboo

works, thanks :)

claudiogg88 avatar Apr 08 '14 17:04 claudiogg88

Do you have Date fields?

My date field in _form.gsp like <bs:datePicker name="tradeDate" precision="day" value="${itemStatusInstance?.tradeDate}" /> always complain "Property tradeDate must be a valid Date" and I don't know why?

The date format is (yyyy-MM-dd) by default.

magicboo avatar Apr 08 '14 18:04 magicboo

yeap, I have the same problem, maybe must edit/fix the file src/scaffolding/renderEditor.template ???

claudiogg88 avatar Apr 08 '14 18:04 claudiogg88

But I still didn't find the solution. Do you? Or should we change to not using bs:datePicker?

magicboo avatar Apr 08 '14 18:04 magicboo

nop, not yet.

claudiogg88 avatar Apr 08 '14 18:04 claudiogg88

I have not tried to use the date feature but I found that both editor template and the _form.gsp in /src/scaffolding have issues - one of the issues I have been dealing with is the implicid unique equal true (default) - to my recollection the _form.gsp made a code change to figure out the reqiured attribute but it seemed it did not work right. Could this be the problem for you? (Also see issue #80 for the renderEditor.template - similar issues were found) Hope this helps.

pbb6w7 avatar Apr 09 '14 12:04 pbb6w7

<bs:datePicker name="tradeDate" precision="day" value="${itemStatusInstance?.tradeDate}" /> is rendering to <input id="tradeDate" name="tradeDate" class="datepicker null" size="16" type="text" value="2014-04-11" data-date-format="yyyy-mm-dd"/> and I can't find the point that grails do the validation (because I didn't add any constrain)

I found a solution to add @BindingFormat('yyyy-MM-dd') before my date field in domain class solve the date binding issue. (http://www.jellyfishtechnologies.com/binding-date-in-grails-using-bindingformat/)

But, is this the best (or suggested) way to bind the date field in grails 2.3.x?

magicboo avatar Apr 11 '14 00:04 magicboo

renderEditor.template is wrong, I fixed http://pastebin.com/tZP7ec6H

claudiogg88 avatar May 02 '14 01:05 claudiogg88