Re: A few Quickform questions
| From: | Justin Patrin | Date: | Sun, 02 Jan 2005 08:27:31 +0000 |
| Subject: | Re: A few Quickform questions | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16557@lists.php.net to get a copy of this message | ||
On Sun, 02 Jan 2005 08:56:29 +0100, Janus & Heidi <janusjr@tdcadsl.dk> wrote:
> Hi, I have a few Quickform questions, hope you can help me :)
>
> 1. How do I check if an item has been selected in a select. At the
> moment I am doing this:
>
> $form->addElement('select', 'php_version', 'PHP version',
> array('select' => '-- select one please --', '3.x' =>
> '3.x', '4.x' =>
> '4.x'));
> $form->addRule('php_version', 'Please select the PHP version',
> 'regex', '/[^(select)]/');
>
> But surely that must be a better way besides using a regex like this ?
Technically 'select' is a valid selection. HTML_QuickForm has no way
of knowing that this isn't a valid option. This is why you have to
supply a rule which tells it that 'select' is *not* a valid option.
>
> 2. I found a tutorial where the author is extending HTML_QuickForm like
> this, building the main form in the constructor:
>
> http://www.pookey.co.uk/pear/qf_hello2.phps
>
> Is this a good way to use HTML_QuickForm, to me it seems a bit weird ?
There is no reason to extend HTML_QuickForm unless you're going to be
using the same form in a bunch of places. If, for instance, a bunch of
forms in your app have the same starting fields or some of the same
hidden fields you might want to do something like this. For a form
which is used in one place, you're probably better off just making a
form object and adding the elements in-line.
If your forms are large or you just have a lot of them, breaking each
out into its own object can't hurt. It mostly just how you want to
program things.
You may also want to extend if you want to set up some special
processing or custom handling, but again this is mostly only useful if
the new stuff is reusable and used in multiple places.
>
> 3. Does QuickForm work with PHP5 (E_ALL) ?
All PEAR packages should work with E_ALL in PHP4 and PHP5 (except a
few which do bad htings like set $this). Unless a package says it is
PHP5 only, it is not E_STRICT compatible.
>
> Janus Roenne
>
--
Justin Patrin