RSS | technovelty home | page of ian | ianw@ieee.org
I from time to time want to create a quick static web form to run where PHP etc isn't involved. The best way I've found to do this is with the HTML_QuickForm PEAR package.
To install it on Debian, just install the php-pear
package and run sudo pear install HTML_Common
HTML_QuickForm and then you can easily create really nifty
forms.
For example, the comments form below was created with the following input.
<?php
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('comments_form');
$form->addElement('header', null, 'Add a comment');
$form->addElement('text', 'author', 'Name', array('size' => 50, 'maxlength' => 50));
$form->addRule('author', 'Please enter a name', 'required', null, 'client');
$form->addElement('text', 'email', 'Email', array('size' => 50, 'maxlength' => 50));
$form->addRule('email', 'Please enter an email', 'required', null, 'client');
$form->addElement('text', 'url', 'Website', array('size' => 50, 'maxlength' => 50));
$form->addElement('textarea', 'body', 'Comment:', array('rows'=>10,'cols'=>50));
$form->addRule('body', 'Please enter a comment', 'required', null, 'client');
$form->addElement('submit', null, 'Submit');
$form->display();
?>
It automagically does client side javascript to do first level
validation and makes the form look quite nice. You can just run
php file.php on the command line to scrape out the plain
HTML.
posted at: Wed, 04 Jan 2006 16:32 | in /web | permalink | add comment (0 others)

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.