ziftech
ziftech

Reputation: 747

Grails 3 - f:table - how to display property of related class

There is 2 simple classes:

class Entity{
Integer id
Status status
String type
}

class Status{
Integer id
String name
}

I just need to replace representation of "status" field in Entity list and edit - instead of my.appStage : 1 -> "normal" How to do it?

Upvotes: 0

Views: 464

Answers (1)

Mike W
Mike W

Reputation: 3932

Create a file named _displayWrapper.gsp in the following directory:

/views/entity/status

Then in the file add the following:

${value.name}

Assuming you just want to print the text 'normal'.

There are other ways to achieve this, see docs.

Update after question:

For f:all you could add _wrapper.gsp to the directory mentioned above and add the following:

<div class="fieldcontain required">
    <label for="status">Status</label>
    <g:select name="status" from="${Status.all}" optionValue="name" optionKey="id" value="${entity?.status}"/>
</div>

Upvotes: 2

Related Questions