Re: QuickForm Controller, Defaults, and Dynamic Form Elements

From: Date: Wed, 13 Sep 2006 15:25:06 +0000
Subject: Re: QuickForm Controller, Defaults, and Dynamic Form Elements
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25123@lists.php.net to get a copy of this message
On 9/12/06, Michael C <mc5941@gmail.com> wrote:
Hi Alexey, Thanks for the responce:
My hope here is when I call $this->controller->exportValues() I'll get a result set inclusive of the default data, and then I can go on my merry way and build out the dynamic form. So much for that theory.... Any ideas on how I can accomplish this?
I fail to see where exactly is the problem. You can iterate over raw POST data in your buildForm() method? Why can't you iterate over some data fetched from a database as well? True, i could run over the data I used to set the defaults to then build out the form when a user goes back to edit their data. I was just hoping that I can limit my check to POST data and exportValues(). This simplies things considerably. Otherwise, I need to check three++ sets of data in order to figure out what elements to add to the form.
I'm not sure how you expect form elements to appear when you don't create them. setDefaults() does just what it says, sets defaults. It doesn't create form elements. As you said, the user "goes back to edit" so the POST data is no longer defined. You need to store it somewhere or you'll lose it.
It is really simple when the user comes in for the first time and is creating a data set. But if they are editing a data set, I will need to do some funky checks to ensure that I am restoring the elements properly. Since they can dynamically define / remove elements that have an effect across other pages, doing a simple restore from the database per page will possibly break things, especially on secondary pages that are dependant upon data defined on the first page. Oh well, no magic bullets here. I guess I'll have to do some real work :)
-- Justin Patrin

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