Re: DB_DataObject_FormBuilder

From: Date: Mon, 03 Jan 2005 22:46:44 +0000
Subject: Re: DB_DataObject_FormBuilder
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16574@lists.php.net to get a copy of this message
On Mon, 03 Jan 2005 14:11:19 -0800, Ed Greenberg <edg@greenberg.org> wrote: > I'm using FormBuilder (a fine extension to DB_DataObject and QuickForm. > Great idea!) > > Here's my code. Really complex stuff :) > > //set up DB_DataObject config settings > $do = DB_DataObject::factory($table); > if(is_numeric($value)) $do->get($value); > $formBuilder = DB_DataObject_FormBuilder::create($do); > $form = $formBuilder->getForm(); > if($form->validate()) { > $form->process(array(&$formBuilder, 'processForm'), false); > //this is optional, you can comment out this to make the form appear for > editing again FormBuilder doesn't handle where you go, it only handles creation and processing of a form. You decide what to do when the form validates or is processed. If you want to redirect, put something like this here: header('Location: http://www.example.com/success.php'); exit; > $form->freeze(); > } > echo $form->toHtml(); > > Everything works fine except that I need to control where we go after a > successful insert. Rather than redisplaying the (frozen) form, I'd like to > go back to whence I came. > > I can't figure out where in FormBuilder I tell the object what to do when > done. It always seems to come back to where we are. > > Perhaps I should detect a successful processing run and then issue a > redirect, or perhaps there is an argument to the process method that I'm > missing? Or something else I'm missing. > > Or, maybe I need to code this in the postprocess callback. > > Or maybe I have no clue. > > What, if anything, is the "best practice"? > > Thanks, > </edg> > -- Justin Patrin

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