fluid form validation hell

raw

phork0.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!-- get a form-wide error -->
<f:form.validationResults for="contactReq">
  <f:if condition="{validationResults.flattenedErrors}">
    <f:for each="{validationResults.flattenedErrors}" as="errors" key="propertyPath">
      <f:if condition="{propertyPath}==''">
        <f:for each="{errors}" as="error">
          <f:if condition="{error.code}==1464702066">
            <v:variable.set name="errorStyleMailorphone" value="display:block"/>
          </f:if>
        </f:for>
      </f:if>
    </f:for>
  </f:if>
</f:form.validationResults>
 
<!-- errors for single fields -->
<f:form.validationResults for="contactReq.name" as="errors">
  <f:if condition="{errors.flattenedErrors}">
    <v:variable.set name="errorClassName" value="error"/>
  </f:if>
</f:form.validationResults>
 
<f:form.validationResults for="contactReq.email" as="errors">
  <f:if condition="{errors.flattenedErrors}">
    <v:variable.set name="errorClassEmail" value="error"/>
  </f:if>
</f:form.validationResults>
 
<f:form.validationResults for="contactReq.phone" as="errors">
  <f:if condition="{errors.flattenedErrors}">
    <v:variable.set name="errorClassPhone" value="error"/>
  </f:if>
</f:form.validationResults>
 
<f:form.validationResults for="contactReq.message" as="errors">
  <f:if condition="{errors.flattenedErrors}">
    <v:variable.set name="errorClassMessage" value="error"/>
  </f:if>
</f:form.validationResults>
 
Christian Weiske Christian Weiske
owner

History