Re: My QF is posessed

From: Date: Mon, 31 Jan 2005 18:53:38 +0000
Subject: Re: My QF is posessed
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17295@lists.php.net to get a copy of this message
On Sun, 30 Jan 2005 22:35:18 -0800, Ken Restivo <ken@restivo.org> wrote: > I think QF may be posessed of an evil spirit. > > I validate form A, which has a hidden var disp_state set to "A". After validating and > processing, $_REQUEST['disp_state'] === 'A'. > > Then I instantiate a totally new form B. I then $formB->addElement('hidden', > 'disp_state', 'B'). And when QF creates this element, it *ignores* my value > passed in to addElement, and instead insists on placing into it the value "A". If I > print_r the element immediately after addElement'ing it, "A" is in there, not > "B" which I specified. I have no code of my own in there between addElement and print_r. > Who or what is making the decision to put a different variable in there? Only the shadow knows. > > But then if I explicitly setValue("B") afterwards, it stays in there, and the > behaviour I expected is exhibited. > > I'm using $trackSubmit, but that doesn't look like it is the problem. > > Since I found the setValue workaround and I wasn't able to isolate this in a testscript > suitable for a proper bug report, I'm just going to raise an eyebrow and move on from here. > It's apparently some interaction with the rest of my application, but I can't imagine > what. I'm on a tight deadline so I haven't time to do a lot of detective work on this, but > I'm still curious what code of mine could be causing this strange behaviour? > You can use $form->setConstants() to force the value to what you want. Setting the value in addElement only sets the "default". Anything else (including $_REQUEST) can override it. Try using trackSubmit on both forms as Alexey suggested and see if it works. -- Justin Patrin

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