tags:

views:

13

answers:

1

I have something like this:

Class person {
    string name
    string status
    boolean working
    boolean vacation
}

static constraints = {
   name()
   status(inList: ["Active","Inactive"])
}

What I need is to show the working and vacation fields in the create and edit views, only if Active is selected in status. I searched and read alot but can't find a way, maybe I'm missing something since I'm new to grails. Any help is appreciated. Thank you

+1  A: 

This can not easily be done with Dynamic scaffolding. You will need to edit the generated views to add the logic in. See the GSP tag refference for if at http://grails.org/doc/latest/ref/Tags/if.html In your case something like

<g:if test="$person.active ==true">
Insert GSP code to edit data here.
</g:if>
Jared
Thank you for your reply. I tried doing that, in the create and edit views I put an <g:if test="${status == 'Active'}"> around the code that shows the "working" field, and I changed my class definition to string status = 'Inactive' so as to initialize with a value. The thing is, in fact the "working" field disappears in create view but not in edit view, and if I change the status to 'Active' it still doesn't show
Bufunfa
Got it, had to change <g:if test="${status == 'Active'}"> to <g:if test="${personInstance?.status == 'Active'}">. Now if I only could make the change happens as soon as the value is changed that would be great. for the moment only when I update the record.I update here if I can make it. I appreciate any help in this.thank you
Bufunfa