| Author |
Message |
|
stormqueen
Joined: September 6th, 2009, 9:29 pm Posts: 9 Location: Düsseldorf, Germany
|
 Marking required input fields
Hi,
I want to assing a special css class to an input field when the according field in the bean is required.
I have a domain class like this
class Dummy { String iAmRequired static constraints = { iAmRequired(nullable: false) } }
and a create.gsp where I assign values to this class like this
<input type="text" name="iAmRequired" >${fieldValue(bean:dummy, field:'iAmRequired')}</input>
Is there something like class="value ${hasErrors(bean:dummy,field:'iAmRequired','errors')}" with what I can do it?
|
| September 8th, 2009, 3:41 pm |
|
 |
|
Flow
Joined: September 5th, 2009, 2:47 pm Posts: 17 Location: Graz, Austria
|
 Re: Marking required input fields
Hi! Maybe you can try something like this in your Controller to find out dynamically which properties have a blank constraint applied. Collect the keys that have the constraint you want to check. In the view you could probably use a nifty prototype script that adds some css class or style to your input fields. BTW: http://jira.codehaus.org/browse/GRAILS-270 is what you need I think. Be patient and stay tuned  I'm also quite new to Grails and maybe someone here knows a much more elegant solution. kind regards, hth, Flo
|
| September 8th, 2009, 4:46 pm |
|
 |
|
Flow
Joined: September 5th, 2009, 2:47 pm Posts: 17 Location: Graz, Austria
|
 Re: Marking required input fields
Hi! Maybe a little bit late but I blogged about how you can solve this problem: http://www.caffeinated.at/2009/09/visua ... eneration/Flo
|
| September 17th, 2009, 7:44 pm |
|
 |
|
stormqueen
Joined: September 6th, 2009, 9:29 pm Posts: 9 Location: Düsseldorf, Germany
|
 Re: Marking required input fields
Hi, thanks for your answer. The Jira Issue is exactly what I need  Your first post helped me, the second comes a litte late... I solved this Problem by writing: class="required ${Dummy.constraints?.iAmRequired?.nullable}" so I get class="required true" or class="required false" Maybe not the best way but it works kind regards stormqueen
|
| September 17th, 2009, 9:16 pm |
|
 |
|
tim_yates
Joined: September 15th, 2009, 11:52 am Posts: 6
|
 Re: Marking required input fields
There's the bean fields plugin Marc Palmer released earlier this month: http://grails.org/plugin/bean-fieldsMight help you out a bit
|
| September 24th, 2009, 8:25 am |
|
 |
|
lucastex
Site Admin
Joined: August 31st, 2009, 11:23 pm Posts: 106 Location: São Paulo - Brazil
|
 Re: Marking required input fields
I suggest you all use Marc`s plugin, this is an awesome functionality that IMHO, should be added to grails core.
[]s,
_________________ Lucas Frare Teixeira lucastex at gmail.com twitter: @lucastex http://blog.lucastex.com
|
| September 24th, 2009, 11:14 am |
|
|