Re: QFC - what does the container do?
| From: | Alexey Borzov | Date: | Thu, 18 Mar 2004 14:03:17 +0000 |
| Subject: | Re: QFC - what does the container do? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11363@lists.php.net to get a copy of this message | ||
Hi!
Daniel Kopp wrote:
I am using QFC quite some time now but I still did not fully get what the container does. There are: defaults, values, constants, valid and I think I basically got, what they are for (but I am not sure ...) -defaults : values for a new blank form (put there on session start)The default values, set by Controller::setDefaults()
The "constant" values, set by Controller::setConstants(). See QuickForm docs for the difference between default and constant values.-values : the values that come back from the user - before processing-constants : the values after processing (checked)
-valid : for modal forms shows whether or not a form is filled in
correctly already
Not only for modal forms. It indeed keeps the validation status:
* null if the form was never submitted
* result of validate() call (true or false, naturally) if the form was already submitted.
I guess this is very useful if you are working with a multipage-form that has to be filled in completely first and will be written in a database in the very end, when all the data is complete. For me - I am using controller different. I am basically paging through data most of the time with the possibility to enter new data (not often enough that it would make sense to use defaults) So I have forward/backward/jump to data-sets and I never really know whether I should use values or constants to put my data in. Now I usually use constants to put in what I put out to the browser and values for what comes back. But what I would really like to know is: When does the controller do anything on the container array (especially values and constants) Does it do anything at all in these fields?The defaults and constants fields are changed on call to setDefaults() and setConstants(), respectively. The values and valid fields are changed when the form is submitted, if you write your own Actions you'll have to handle this. You generally should *not* write to defaults and constants.
Another question is: When I get my data back I would like to compare constants and values and update the DB in case there is any difference. But there is also a lot of other stuff in values like the buttons and some control-fields (if I would not use CSS to hide them they would be hidden fields :-)) so - there is always a difference and I usually update without effecting data ...You can always filter out the buttons and control-fields, just as Controller does itself in exportValues().