On 1/31/07, Derek Watson <[EMAIL PROTECTED]> wrote:
> I see that as of 0.546, form validate() calls get passed to sub-forms by
> default,
>  * Added a cascade parameter to validate(), which defaults to true.
>  (Suggested by Guillermo Roditi)
> Which is great - exactly what I needed! But there is an order-of-operations
> problem for me, because validate() calls the sub-form validation before it
> calls the per-field validation. If my form validation routine says
>
> $self->field('password')->error('Password and confirm do
> not match');
>
> then it will be overwritten immediately after by the per-field validation,
> which unconditionally sets
>
> $self->error(undef);
>
> on every call.  Is it possible to a) Perform the field validation before the
> form validation or b) avoid wiping out existing field errors on every call
> to field->validate()?

I'm aware of this issue (it's bitten me too).  Here's what's
happening, in a bit more detail.  Consider a form A with fields a1 and
a2.  Calling validate() on that form does the following:

    1. Validate field a1: $form->field('a1')->validate()
    2. Validate field a2: $form->field('a2')->validate()

Now say there's a form B with fields b1 and b2 and a nested form A
with fiends a1 and a2.  Calling validate() on that form currently does
the following:

    1. Validate sub-form A:
        1.1. Validate field a1: $sub_form->field('a1')->validate()
        1.2. Validate field a2: $sub_form->field('a2')->validate()
    2. Validate field a1: $form->field('A.a1')->validate()
    3. Validate field a2: $form->field('A.a2')->validate()
    4. Validate field b1: $form->field('b1')->validate()
    5. Validate field b2: $form->field('b2')->validate()

The problem is that the fields in the nested form are validated twice:
first as part of the validation of sub-form A, and again as part of
the "flattened" list of all fields in the entire form.

I think the solution is pretty simple: don't re-validate fields in
sub-forms when the "cascade" option is on (which it is, by default).
I plan to include this change in the next release.

-John

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to