RE: [PEAR] QF/QFC: a question and a request

From: Date: Wed, 17 Dec 2003 16:59:11 +0000
Subject: RE: [PEAR] QF/QFC: a question and a request
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9623@lists.php.net to get a copy of this message
> -----Original Message----- > From: Bertrand Mansion [mailto:bmansion@mamasam.com] > Sent: 16 December 2003 14:58 > To: Massimiliano Bariola; pear-general@lists.php.net > Subject: Re: [PEAR] QF/QFC: a question and a request > > > <m.bariola@redlinkitalia.it> wrote : > > > Hello, > > > > keeping working on QFC, I was wondering what's the best > way to unset > > the defaults for a controller. > > > > this is my situation: I get to the QFC page like this: > > > > http://blahblah...../myController.php?someparameters=parametervalues > > > > I look at those parameters in $_GET array to load up a > data object > > from the DB and then setDafaults/applyDefaults to the > controller/pages. > > > > running this page on IE and opera, I also would like that if I call > > > > http://blahblah...../myController.php > > > > without parameters, no defaults be loaded and the > forms present > > themselves empty. > > > > Looking at the controller::setDefaults() code, > > > > function setDefaults($defaultValues = null) > > { > > if (is_array($defaultValues)) { > > $data =& $this->container(); > > $data['defaults'] = > array_merge($data['defaults'], $defaultValues); > > } > > } > > > > it seems there is no way to actually instruct it to > delete the > > defaults from a "previous" use of ....myController.php . > > > > I do it now by directly playing with the container's > ['defaults'] > > array. But -- how about adding an optional > parameter to > > setDefaults(), which, if set, actually clears the > defaults for the > > Controller? > > > > Also, adding the possibility for applyDefaults() to apply > to all the > > pages of a Controller if a pagename isn't specified > could be a > > timesaver. > > > > Thanks for your attention (and patience), > > I personally use : > > if (!empty($_GET['somevar'])) { > $controller->container(true); > } > > The parameter set to true will reinitialize your container, > thus unsetting > any previous validation, defaults, constants, submitted values states. I usually reset the container when I want to start over a controller process - this is usually when the person re-visits the PHP script from another page. I simply check the HTTP referer:- if(!stristr($_SERVER['HTTP_REFERER'], $_SERVER["PHP_SELF"])) { // --- Reset the container $wizard->container(true); $wizard->setDefaults(array('conceptType' => $conceptType)); } Requires no parameters to be passed to the script in the URL. Regards, Mike C. ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________

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