Skip to content
This repository has been archived by the owner on Oct 31, 2018. It is now read-only.

Type of g:field tag #82

Open
claudiogg88 opened this issue Apr 8, 2014 · 9 comments
Open

Type of g:field tag #82

claudiogg88 opened this issue Apr 8, 2014 · 9 comments

Comments

@claudiogg88
Copy link

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="" />

@magicboo
Copy link

magicboo commented Apr 8, 2014

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

@claudiogg88
Copy link
Author

works, thanks :)

@magicboo
Copy link

magicboo commented Apr 8, 2014

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.

@claudiogg88
Copy link
Author

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

@magicboo
Copy link

magicboo commented Apr 8, 2014

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

@claudiogg88
Copy link
Author

nop, not yet.

@pbb6w7
Copy link

pbb6w7 commented Apr 9, 2014

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.

@magicboo
Copy link

<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?

@claudiogg88
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants