我正在尝试使用域类从我的数据库中获取country
,state
和city
。但我需要更简单的方法来获取它们。有没有办法通过使用Grails标签获得这些?
<g:countrySelect/>
<div class="form-group">
<div class="col-lg-2"></div>
<div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'country', 'error')} ">
<label class="col-lg-3 control-label" for="country">
<g:message code="account.country.label" default="Country" />
</label>
<g:select id="country" name="country.id" from="${org.preva.Country.list()}"
optionKey="id" value="${accountInstance?.country?.id}"
class="many-to-one" noSelection="['null': 'Choose Country']"
style="width:160px"/>
</div>
</div>
<div class="form-group">
<div class="col-lg-2"></div>
<div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'state', 'error')} ">
<label class="col-lg-3 control-label" for="state">
<g:message code="account.state.label" default="State" />
</label>
<g:select id="state" name="state.id" from="${org.preva.State.list()}"
optionKey="id" value="${accountInstance?.state?.id}"
class="many-to-one" noSelection="['null': 'Choose State']"
style="width:160px"/>
</div>
</div>
<div class="form-group">
<div class="col-lg-2"></div>
<div class="fieldcontain ${hasErrors(bean: accountInstance, field: 'city', 'error')} ">
<label class="col-lg-3 control-label" for="city">
<g:message code="account.city.label" default="City" />
</label>
<g:select id="city" name="city.id" from="${org.preva.City.list()}"
optionKey="id" value="${accountInstance?.city?.id}"
class="many-to-one" noSelection="['null': 'Choose City']"
style="width:160px"/>
</div>
</div>
有没有默认标签?