Re: FormBuilder linkNewValue issue

From: Date: Fri, 20 May 2005 16:10:46 +0000
Subject: Re: FormBuilder linkNewValue issue
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19308@lists.php.net to get a copy of this message
Il 17:58, venerdì 20 maggio 2005, Justin Patrin ha scritto: > On 5/19/05, Alessandro Pasotti <ale.pas@tiscali.it> wrote: > > Il 02:23, venerdì 20 maggio 2005, Justin Patrin ha scritto: > > > On 5/19/05, Alessandro Pasotti <ale.pas@tiscali.it> wrote: > > > > Hello, [...] > > > > Thanks for the quick answer, I implemented commit/rollback stuff and now > > it works great. > > > > I have another problem yet (the DB design is unfortunately not my > > choice): > > > > * Imagine you are adding a new record in the same scenario described > > above, * When you call validation method _before_ the subform is > > processed it fails because the required FK for the linked table is null. > > * To make it work, I had to modify fb->processForm to posticipate > > validation of the main form _after_ the subform is processed. > > > > Is there a more "elegant" solution for this problem? > > 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 --------- --------- id PK .... user_id FK <--> id PK * I choose --New Value-- for user_id and fill in the subform, then fill main form values and submit * processForm starts and try to validate main form user_id which must be NOT 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 has been processed in the inner loop. This is only necessary in case of linkNewValues have been entered. This way it works since validation of main form happens after PK "id" of sub form has been defined (from the DB). I was just asking myself of a better way (I don't like to change the code in processForm or subclass it). TIA -- Alessandro Pasotti ICQ# 245871392 Linux User #167502

« previous php.pear.general (#19308) next »