[ 
https://issues.apache.org/jira/browse/TAP5-2475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14519369#comment-14519369
 ] 

Nicolas Bouillon commented on TAP5-2475:
----------------------------------------

If the form is configured with clientValidation="NONE", when each field is 
leaved blank but is marked as required, then the error message is also the same 
on each field, containing the label of the last form field (i.e : each field 
gets the message "field three is required").

> Form Field in Loop : on validation error all field get the same value
> ---------------------------------------------------------------------
>
>                 Key: TAP5-2475
>                 URL: https://issues.apache.org/jira/browse/TAP5-2475
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.4
>            Reporter: Nicolas Bouillon
>            Priority: Blocker
>              Labels: form, validation
>             Fix For: 5.4
>
>         Attachments: tapestry-test.zip
>
>
> On 5.4-beta-26.
> Given a template like this :
> {code:xml}
> <t:form t:id="form">
>         <t:errors/>
>         <t:loop source="items" value="item">
>             <div>
>                 <t:label for="field"/>
>                 <t:textfield t:id="field" value="value" label="prop:item"/>
>             </div>
>         </t:loop>
>         <div>
>             <t:submit/>
>         </div>
>     </t:form>
> {code}
> If the validation of the form fails (global validation), the page is 
> displayed with all the field containing the same value, the last one.
> {code:title=Index.java|borderStyle=solid}
> public class Index {
>     private Map<String, String> values;
>     @Property
>     private String item;
>     public String[] getItems() {
>         return new String[]{"one", "two", "three"};
>     }
>     public void setValue(String value) {
>         if (values == null) {
>             values = new LinkedHashMap<>();
>         }
>         values.put(item, value);
>     }
>     public String getValue() {
>         if (values == null) {
>             values = new LinkedHashMap<>();
>             for (String item : getItems()) {
>                 values.put(item, item);
>             }
>         }
>         return values.get(item);
>     }
>     @Inject
>     private AlertManager alertManager;
>     @InjectComponent
>     private Form form;
>     public void onValidateFromForm() {
>         form.recordError("Purposely generated error");
>     }
>     public void onSuccessFromForm() {
>         for (Map.Entry<String, String> entry : values.entrySet()) {
>             alertManager.info(entry.getKey() + " = " + entry.getValue());
>         }
>     }
> }
> {code}
> Any help will be welcomed to guide me to provide a patch.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to