Re: setDefaults vs constants vs setValue
| From: | Alexey Borzov | Date: | Mon, 10 Oct 2005 05:39:05 +0000 |
| Subject: | Re: setDefaults vs constants vs setValue | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21302@lists.php.net to get a copy of this message | ||
Hi,
Ken Restivo wrote:
I just discoverd that, despite using QF for over a year-and-a-half now, I don't have a really deep understanding of when to use submitted values ($_REQUEST), setDefaults, setValue, and setConstants. The docs are good on all three, but don't describe the *interations* between all three. What I want to know is: 1) What is the precedence of each (rock, paper, scissors)? I thought that setDefaults were overridden by setValue, but in my own application I've discovered that's wrong. setDefaults will clobber what I set with setValue, if I setValue first. So specifically, which of these will clobber the others *IFF* there is some previous value already set, and which of the four ($_REQUEST, setDefaults, setConstants, setValue) can set them such that they cannot be overriden by others of the three? Obviously setConstants overrides $_REQUEST and setDefaults, but what other interactions are there? Do any of the three check first and decline to clobber existing values?There are values that are kept in the form object (submit values, defaults and constants) and there is a display value, which is kept in the element. This display value is either loaded from the form, using the documented precedence constants > submit > defauls, or is directly set via setValue(). The values are taken from the form in 3 cases: 1) setDefaults() called, 2) setConstants() called, 3) element is added to the form. Setting the display value via setValue() or loading it from the form will "clobber" the previous value. In short: if you realy intend to use setValue(), that should be the last thing you do to change the element's value, in other case it will be overriden.