Bufunfa
Bufunfa

Reputation: 1

How to display field based on another one

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

Upvotes: 0

Views: 292

Answers (1)

Jared
Jared

Reputation: 39913

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>

Upvotes: 1

Related Questions