* @package PHP_XFORMS * @subpackage EXAMPLE * */ function fake_validation_callback($data) { if (rand(0, 100) > 50) throw new Exception("Server-side validation error!"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { include_once dirname(__FILE__) . '/../PhpXforms.php'; $px = new PhpXforms(dirname(__FILE__) . '/schema.xsd'); $px->setValidatorCallback('fake_validation_callback'); $px->setDefaultExceptionHandler(); $px->setDefaultSuccessProcessor(); $px->run(); exit(); } header('Content-Type: application/xhtml+xml; charset=utf-8'); echo "\n"; ?> PhpXforms Example

PhpXforms Example

2006-09-05
Example date field: Example title: Minimum 1, maximum 255 symbols Example text: Save

Note:

  1. To run the example you will need Firefox web-browser with XForms extension. Both are free software, and you may download them at http://www.mozilla.com/ and https://addons.mozilla.org/firefox/824/ respectively.
  2. The server-side validation in this example is just a fake one. It will randomly generate an error or pass validation.