Home > Archive > PHP Pear > May 2005 > Re: [PEAR] FormBuilder linkNewValue issue
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] FormBuilder linkNewValue issue
|
|
| Justin Patrin 2005-05-26, 8:59 pm |
| On 5/19/05, Alessandro Pasotti <ale.pas@tiscali.it> wrote:
> Il 02:23, venerd=EC 20 maggio 2005, Justin Patrin ha scritto:
able[color=darkred]
gain[color=darkred]
the[color=darkred]
>=20
> Thanks for the quick answer, I implemented commit/rollback stuff and now =
it
> works great.
>=20
> I have another problem yet (the DB design is unfortunately not my choice)=
:
>=20
> * Imagine you are adding a new record in the same scenario described abov=
e,
> * When you call validation method _before_ the subform is processed it fa=
ils
> because the required FK for the linked table is null.
> * To make it work, I had to modify fb->processForm to posticipate validat=
ion
> of the main form _after_ the subform is processed.
>=20
> Is there a more "elegant" solution for this problem?
>=20
I don't understand. What's failing? The linkNewValue value is "--New
Value--" so it should pass the required rule. How exactly are you
validating it? If you're using your own validation scheme, I suggest
you check for the linkNewValue value.
--=20
Justin Patrin
| |
| Alessandro Pasotti 2005-05-26, 8:59 pm |
| Il 17:58, venerd=EC 20 maggio 2005, Justin Patrin ha scritto:
> On 5/19/05, Alessandro Pasotti <ale.pas@tiscali.it> wrote:
[...]
[color=darkred]
>
> I don't understand. What's failing? The linkNewValue value is "--New
> Value--" so it should pass the required rule. How exactly are you
> validating it? If you're using your own validation scheme, I suggest
> you check for the linkNewValue value.
I don'use any custom validation, this is what happens:
MainForm Sub Form
=2D-------- ---------
id PK ....
user_id FK <--> id PK
* I choose --New Value-- for user_id and fill in the subform, then fill mai=
n=20
form values and submit
* processForm starts and try to validate main form user_id which must be NO=
T=20
NULL, but now it's NULL since the Sub Form has not been processed yet
* validation fails
To make it work I had to posticipate validation of mainform _after_ subform=
=20
has been processed in the inner loop. This is only necessary in case of=20
linkNewValues have been entered.
This way it works since validation of main form happens after PK "id" of su=
b=20
form has been defined (from the DB).
I was just asking myself of a better way (I don't like to change the code i=
n=20
processForm or subclass it).
TIA
=2D-=20
Alessandro Pasotti
ICQ# 245871392
Linux User #167502
|
|
|
|
|