Re: DO FB - how to set a password empty...
| From: | Justin Patrin | Date: | Wed, 10 Nov 2004 21:24:37 +0000 |
| Subject: | Re: DO FB - how to set a password empty... | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15427@lists.php.net to get a copy of this message | ||
On Wed, 10 Nov 2004 10:21:39 -0800, Ken Restivo <ken@restivo.org> wrote:
> On Wed, Nov 10, 2004 at 09:02:38AM -0800, Justin Patrin wrote:
> >
> > 1) You can try setConstants() on the form in postGenerateForm() for tha DO.
> > 2) You could use a preDefElement in preGenerateForm
> > 3) You could override the get() function for the DO to not get the PW
> > (then you'd probably want a getPassword function which specifically
> > gets it).
> > 4) You could call setDefaults() on the form in postGenerateForm() to
> > re-set the default
> > 5) There are probably other ways
> >
>
> This raises a question that has been paralysing me for weeks. There are
> *so* many different hooks and ways to customise FormBuilder forms, that I
> honestly don't know how to approach it without creating a mess of unmanageable
> spaghetti code.
>
> I'd like to pick one method and stick with it throughout my applications. So
> that when someone (like me, a few years later) looks at the code, and wonders
> where the hell such-and-so behaviour or bug is coming from, I know where to
> look. If I haphazardly mix and match these approaches, I'm going to have a
> disaster on my hands.
>
> Is there a "best practices" recommendation as to where and when to use each
> of these techniques? Pros and cons of each? Any gotchas with any particular
> approach, that I should be aware of?
>
Well, all the different methods are for different solutions. I agree
that FormBuilder has a lot of options and that many problems often
have multiple different solutions.
Here's my personal take on how to configure FormBuilder.
Always use 'fb_' member vars in the DOs when setting table specific
options. Allow FB to create and populate elements whenever you can
(Use preDefElements only when you must). Use preGenerateForm() and the
other pre/post callbacks whenever you need to set options or do
special processing that can't be done with normal DO member vars.
As for how to do particular tasks....well, I have examples up on the
doc wiki of how *I* have solved many problems.... and you can always
ask here for more.
--
Justin Patrin