Вопрос

I'm performing inline validation on fields as the user tabs between them. A problem occurs when there is more than one error against a field i.e both errors are shown. I only want to show one error (The first one for arguments sake).

Is there are different tag to deal with this?

<jqvalui:renderError for="title">
    <g:eachError bean="${objInstance}" field="title"><g:message error="${it}" /></g:eachError>
</jqvalui:renderError>

Thanks

Это было полезно?

Решение

So essentially you just have to use the errors themselves instead of using the tags provided for you.

<g:hasErrors bean="${objInstance}" field="title">
    <g:message error="${objInstance.errors.getFieldErrors("title")[0]}" />
</g:hasErrors>

Другие советы

I know it's like a hack but if no exact solutions... Consider adding a flag or a counter and set/test it inside the loop:

<g:set var="isErrorShown" value=""/>
<g:eachError bean="${objInstance}" field="title">
    <g:if test="${!isErrorShown}">
        <g:message error="${it}"/>
        <g:set var="isErrorShown" value="TRUE"/>
    </g:if>
</g:eachError>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top