NYCPHP Meetup

NYPHP.org

[nycphp-talk] HTML_QuickForm_Controller question

Jayesh Sheth jayeshsh at ceruleansky.com
Thu Sep 23 12:37:26 EDT 2004


Hello all,

I have been quiet for the last month (or two) because I have busy with 
various things.

I have a question now, and I hope someone on the list will be able to help.

I have been using (the PEAR library) QuickForm ( 
http://pear.php.net/package-search.php?pkg_name=quickform&bool=AND&submit=Search 
)  in conjunction with the HTML_QuickForm_Controller 
(http://pear.php.net/manual/en/package.html.html-quickform-controller.php 
) add-on package.

I am using the QuickForm Controller package to build a multi-page form, 
otherwise known as a "wizard". There will be 3 - 5 pages. If all the 
info on the first page validates, the user is taken to the second page. 
If not, then the errors are highlighted. Since the whole form has a lot 
(100+) fields, the multi-page format is necessary.

Within this multi-page format, I wanted to do something like the following:

1) On the first page, the user is asked "How many books do you have?"
2) If the user chose 5 books on the first page, then 5 sets of fields 
will be shown on the second page, each with fields such as title, 
author, isbn, etc.
3) For this example, we will assume that the person cannot have more 
than 10 books

The QuickForm Controller package uses session variables to hold data 
from each page of the wizard. The thing is, I cannot how to access a 
piece of information (session variable) from another page. I.e.,on page 
2, I want to be able to say "if 2 books were specified on page 1, then 
use a loop to add  xyz form fields for each book."

If I were using session variables directly myself, I would know how to 
do it immediately. But while the QuickForm and the QuickForm add-on 
package are both very powerful, they are also very complex.

The reason I am using them is that creating a complex multi-page form 
(with so many form fields and umpteen validation rules) would quickly 
turn into spaghetti code without such libraries.

So, anyone have experience with this or a useful link?

Thanks in advance!

- Jay
PS: David Sklar's PHP Tools book has information on the main QuickForm 
library, but not on the Controller add-on. It seems that online 
information for the controller is quite scant.



More information about the talk mailing list