Re: setDefaults vs constants vs setValue
| From: | Justin Patrin | Date: | Mon, 10 Oct 2005 02:55:09 +0000 |
| Subject: | Re: setDefaults vs constants vs setValue | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21300@lists.php.net to get a copy of this message | ||
On 10/9/05, Ken Restivo <ken@restivo.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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?
>
> 2) When to use each? What typical situations would you use one or the other? When *not* to use
> each of the three? At which stage in the form are each most appropriate?
>
> If there already is a good compare-and-contrast tutorial (or a table, is really what I'm
> looking for), please feel free to just point me at it. But there is so much "flexibility"
> with all these different methods that I'm just befuddled trying to figure out how they
> interact.
>
> So far it looks like the order of precedence is:
> a) setconstants
> b) setdefaults
> c) setvalue
> d) $_REQUEST
>
IMHO it's:
constants - if something is constant it can't be changed by anything
else (even submitted values)
$_REQUEST - submitted values take precedence over everything but constants
defaults and setvalue - the order you set these in makes a difference.
Use one or the other.
--
Justin Patrin