pear/html_quickform2
HTML_QuickForm2 is a PEAR package for building, validating, and rendering HTML forms in PHP. It supports standard and custom elements, server- and client-side validation (with combinable rules), multipage/wizard forms, and pluggable renderers, rules, and elements.
This is a repository for PEAR HTML_QuickForm2 package that has been migrated from PEAR SVN.
HTML_QuickForm2 provides methods to create, validate and render HTML forms. It is a PHP5 rewrite of PEAR HTML_QuickForm and related packages.
Features:
Please report issues via the PEAR bug tracker or Github issues.
Pull requests are welcome.
The package may be installed either with PEAR
$ pear install HTML_QuickForm2
or with composer
$ composer require pear/html_quickform2
Since release 2.1 composer installation relies completely on autoloading and does not contain require_once calls or
use include-path option.
require_once 'HTML/QuickForm2.php'; // Only when installed with PEAR
$form = new HTML_QuickForm2('tutorial');
// Set defaults for the form elements
$form->addDataSource(new HTML_QuickForm2_DataSource_Array([
'name' => 'Joe User'
]));
// Add some elements to the form
$fieldset = $form->addElement('fieldset')->setLabel('QuickForm2 tutorial example');
$name = $fieldset->addElement('text', 'name', ['size' => 50, 'maxlength' => 255])
->setLabel('Enter your name:');
$fieldset->addElement('submit', null, ['value' => 'Send!']);
// Define filters and validation rules
$name->addFilter('trim');
$name->addRule('required', 'Please enter your name');
// Try to validate a form
if ($form->validate()) {
echo '<h1>Hello, ' . htmlspecialchars($name->getValue()) . '!</h1>';
exit;
}
// Output the form
echo $form;
Additional examples are in the docs/examples directory.
...is available on PEAR website
Generated API documentation for the current release is also there.
To test, run
$ phpunit tests/
after installing dependencies with composer. You can also test the installed package with
$ phpunit [PEAR tests dir]/HTML_QuickForm2
Since PEAR package needs its require_once statements re-enabled, please run the helper file before packaging and
installing
$ php pear-package-helper.php
Then to build, simply
$ pear package .pear-package/package.xml
To install from scratch
$ pear install .pear-package/package.xml
To upgrade
$ pear upgrade -f .pear-package/package.xml
How can I help you explore Laravel packages today?