2009/1/19 David Schmidt <davew...@gmx.at>:
> I have been looking for this solution for days now. Thank you so much.
>
> Related to this problem.
> If a constraint of one of the repeatable elements fails, the form is
> re-displayed but the error message is not displayed.

Hi,

I've run into this problem as well. After poking around in the code
this morning, I've tracked the problem down to the call to
$block->repeat in H::F::Model::DBIC. This call apparently discards the
errors in a Repeatable block on any call to
$form->model()->default_values( $my_obj ). I've attempted to fix the
problem, and I've found that adding the following code to
H::F::Model::DBIC works, after a fashion (tested with Integer and
DependOn constraints):

            # store our errors temporarily while the block repeats are built.
            my %error_cache
                = map { $_->nested_name => $_->get_errors }
                     @{ $block->get_fields() };

            my $blocks = $block->repeat($count); # <----- the original
line of code.

            # reinstate the errors.
            foreach my $new_block ( @$blocks ) {
                foreach my $new_field ( @{ $new_block->get_fields } ) {
                    foreach my $error ( @{ $error_cache{
$new_field->nested_name } || [] } ) {

                        # add the error to the field
                        $new_field->add_error( $error );

                        # reparent the error and its constraint.
                        $error->parent( $new_field );
                        $error->processor->parent( $new_field );
                    }
                }
            }


This feels pretty nasty to me (I'm worried I've missed some
reparenting, and there are probably edge cases I don't know about),
but hopefully it may point the way to others better acquainted with
HTML::FormFu internals.

Cheers,

Tim

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to