michele.gherl...@liceoberchet.it schrieb:
michele.gherl...@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
Hello, I tried it with `increment_field_names: 1' but only the constraint
violation in the 1st block gets recognized, while all subsequents
violations are silently ignored. So, if I had, say, 4 blocks generated by
the repeatable with an error in the 4th, this last wrong block data would
be written to the DB. Moreover, only the 1st block, which contains the
error is displayed.
With increment_field_names: 0 I get all errors recognized, but still only
the first block displayed. Should I maybe try to set default_model:
HashRef?
Greets,
Michele Gherlone
Hi Michele,
would you mind creating a test case (that fails) out of your code, that
sets the given parameter values like in the repeatable_repeatable.t test
case I mentioned.
This way I can debug it for you.
Greets,
Mario Minati
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu