Search code examples
htmlgrailsgroovygsp

How to display value of map which is also a map in <g:select> or <select> tag?


I have a map which is like this :

final static def BANK_NAMES = [
        bofa:[fullname:'Bank of America',hasPin:false],
        chase:[fullname:'Chase Bank',hasPin:false],
        wells:[fullname:'Wells Fargo Bank',hasPin:false],
        citi:[fullname:'Citibank',hasPin:false],
        us:[fullname:'US Bank',hasPin:false],
        usaa:[fullname:'USAA',hasPin:false],
        charles:[fullname:'Charles Schwab',hasPin:false]
]

I tried to display value in like this :

<g:each in="${BankConstants.BANK_NAMES}" var="banks">
<option id="status">${banks}</option>
</g:each>

and it shows like this :

bofa={fullname=Bank of America, hasPin=false}

Is there a way to show value of "fullname" in a or tag. Can anyone please help??


Solution

  • You can try:

    <g:each in="${BankConstants.BANK_NAMES}" var="banks">
        <option id="status">${banks.value.fullname}</option>
    </g:each>