Grails g: select tag

I use the g: select tag, for example:

<td><g:select name="newCity"
        id="${'newCity_' +cityData.uid}"
        from="${cityData.name}"
        value="${cityData.someValue}"
        noSelection="${['null':'Select City...']}" class="newCity" />
</td>

which displays the following HTML:

<td>
<select name="newCity" id="newCity_abc" class="newCity" >
<option value="null">Select City...</option>
<option value="A" >A</option>
<option value="B" >B</option>
<option value="C" >C-</option>
<option value="D" >D</option>
</select>
</td> 

However, I want my HTML to look like this: with the class introduced, as I am doing javascript validation:

<td>
<select name="newCity" id="newCity_abc" class="newCity" >
<option value="null">Select City...</option>
<option value="A" class="populated" >A</option>
<option value="B" class="notpopulated" >B</option>
<option value="C" class="populated" >C</option>
<option value="D" class="notpopulated" >D</option>
</select>
</td>

Is it possible?

Do I need to create a custom tag library to achieve this?

Any help would be appreciated, thanks!

+5
source share
1 answer

I do not think this is possible. choosing a tag implementation (which writes tags<option> ) invokes a private methodwriteValueAndCheckIfSelected for filling option, and this is not known about any class names.

2- " " GIRA Grails, , , .

+4

All Articles