zoran119
zoran119

Reputation: 11327

display a boolean as a yes/no radio group

I have a domain class which has a few Boolean properties. The scaffolding feature builds a view which used checkboxes for these properties, but I would really like for these properties to be represented with two radio buttons (Yes/No). What would be the most appropriate way of doing this (a custom tag maybe)?

Upvotes: 1

Views: 2446

Answers (2)

zoran119
zoran119

Reputation: 11327

I ended up using the following radio group:

<g:radioGroup name="amountPayableVariation" labels="['Yes','No']" values="['true','false']" value="${contractInstance?.amountPayableVariation}">
<span>${it.radio} ${it.label}</span>
</g:radioGroup>

Upvotes: 5

Chris
Chris

Reputation: 8099

Install the templates for the scaffolds:

grails install-templates

Then you have can change the templates, which are rendered for each type. Check the file renderEditor.template in your src/templates/scaffolding folder. You have to change the renderBooleanEditor appropriate.

Upvotes: 3

Related Questions