This document is based on questions asked on PEAR general mailing list. You are encouraged to search the list archives to find more verbose answers and examples.
<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
$ pear list
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.
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.
'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:
<?php
$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:
<?php
$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.
"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).
QuickForm does add a 'name'
attribute to the <form>
tag,
which is invalid in XHTML Strict. Quickform does not depend on that attribute since release 3.2.2, and it's only
kept for backwards compatibility. If you desire XHTML Strict compliance and your code does not depend
on said attribute, you can remove it via removeAttribute() method.
'required'
rule does not work for my elements!
'uploadedfile'
rule instead.
'date'
and 'hierselect'
as well.
* denotes required field
and Invalid information entered. / Please correct these fields.
validation messages?
You should use setRequiredNote() and setJsWarnings() methods, respectively.