문제

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