1.
The forms I generate with HTML_QuickForm cannot be submitted. When I look at the
page's HTML source, I see something like <formArray>.
Recent versions of HTML_QuickForm package require HTML_Common package version 1.2.1
(CVS revision 1.8 in HTML/Common.php) to work properly. If
(and only if) an older version of HTML_Common is loaded, these symptoms occur.
Please note that
command may tell you that you
have HTML_Common 1.2.1 installed.
In this case you also have an older version of HTML_Common somewhere and are including it instead
of the proper one. Check your
include_path setting in
php.ini
and/or use PHP's
get_included_files()
function to find out which file you are
really including.
2.
When I pass some GET parameters to the script containing a form, QuickForm thinks
that the form was already submitted, displaying validation errors.
Constructor
of HTML_QuickForm accepts a $trackSubmit parameter.
Setting this to TRUE will make QuickForm check whether the form was actually submitted.
This also helps if you have several forms defined on one page.
3.
How do I set default/constant values for 'date' element?
Date element is essentially a group
of selects, you define the structure of this group
in the 'format' option when
creating the element:
$form->addElement('date', 'foo', 'The date:', array('format' => 'Y m d')); |
Thus you pass the defaults as an array, just like you do with any other group:
$form->setDefaults(array(
'foo' => array('Y' => 2004, 'm' => 9, 'd' => 29)
)); |
To ease using it with database-backed applications, date element also accepts Unix timestamps
(generated by mktime()) and
strings. The strings are processed by strtotime()
functions, so consider its limitations.
4.
I receive weird "Call to a member function on a non-object"
or "Undefined function" errors, especially when dealing with groups.
These errors tend to appear when you have something which is not a
HTML_QuickForm_element in the $elements array
passed to addGroup().
This "something" is usually either a PEAR_Error instance (check for these
or setup a handler) or, if register_globals is switched on in php.ini,
some submitted values (clear the array before adding elements to it).