[html-formfu] Error messages in fields within a Repeatable
Mario Minati
mario.minati at googlemail.com
Tue Jul 28 17:34:39 GMT 2009
michele.gherlone at liceoberchet.it schrieb:
> Hello all!
> I have set up an application in Catalyst where an action has the following
> form:
> ---
> indicator: submit
> elements:
> - type: Repeatable
> increment_field_names: 0
> nested_name: my_rep
> tag: tr
> elements:
> - type: Block
> tag: td
> content:
> elements:
> - type: Label
> name: studente
> - type: Block
> tag: td
> content:
> elements:
> - type: Text
> name: voto_orale
> constraints:
> - type: Regex
> regex:
> '^ms$|^m$|^suf$|^sc$|^10$|^10-$|^\d\+$|^\d\-$|^\d\.25$|^\d\.50$|^\d\.75$|^\d$'
> message: Il voto non e' nel formato corretto...
> - type: Text
> name: data_orale
> constraints:
> - type: Regex
> regex: '\d{2}\/\d{2}'
> message: La data non e' nel formato corretto...
> - type: Text
> name: comment
> - type: Hidden
> name: materia_id
> - type: Hidden
> name: studente_id
> - type: Hidden
> name: quad
> - type: Submit
> name: submit
> attributes:
> value: Registra definitivamente i voti
> filter:
> - TrimEdges
>
> The form is populated with a hashref I create from parameters passed by
> another form, calling $form->model('HashRef')->default_values($hr). The
> Repeatable block works as expected, and I get as many 'tr' as the number
> of hashes inside the array @{$hr->{my_rep}}.
> However, when $form->has_errors is true, I can see the correct number of
> messages, but *ONLY* the first block, while I'd like to get the error
> messages along with all the blocks repeated as when the form is rendered
> the first time (i.e. when !$form->submitted).
> I understand the issue is not simple, and I hope I exposed it as clearly
> as possible.
> My question is whether it's not possible to achieve my goal, or I am doing
> something wrong, and it IS indeed possible to have multiple error messages
> displayed along with the repeated blocks, in a context like the one I have
> depicted here.
> Thank you in advance for the help I really need!
> Regards,
> Michele Gherlone
>
>
Hi Michele,
I suspect the line
increment_field_names: 0
to be the reason, that you only see the errors on the first repetition.
As formfu has no chance to count the different repetitions without
numbered field names.
Try it with
increment_field_names: 1
Greets,
Mario Minati
More information about the HTML-FormFu
mailing list