egroupware_official/phpgwapi/inc/savant2/Savant2/tests/form2.php
Ralf Becker 232252475f patch fixing many depricated functions (eg. posix regular expressions) and features, which fill up the error_log under php5.3 (and will no longer be available under php6).
Patch is mostly created by script in egroupware/doc/fix_depricated.php in separate commit.
I do NOT advice to apply this patch to a production system (it's commited to trunk!), as the automatic modified regular expressions have a good change to break something ...
2009-06-08 16:21:14 +00:00

49 lines
904 B
PHP
Executable File

<?php
error_reporting(E_ALL);
require_once 'Savant2.php';
$Savant2 = new Savant2();
$Savant2->addPath('template', 'templates/');
$Savant2->addPath('resource', 'resources/');
$defaults = array(
'hideme' => null,
'mytext' => null,
'xbox' => null,
'picker' => null,
'picker2' => null,
'chooser' => null,
'myarea' => null
);
$values = array_merge($defaults, $_POST);
$tmp = array();
if ($values['mytext'] == '') {
// required
$tmp[] = 'required';
}
if (strlen($values['mytext']) > 5) {
// max 5 chars
$tmp[] = 'maxlen';
}
if (preg_match('/[0-9]+/', $values['mytext'])) {
// no digits
$tmp[] = 'no_digits';
}
if (count($tmp) == 0) {
$valid = array('mytext' => true);
} else {
$valid = array('mytext' => $tmp);
}
$Savant2->assign('opts', array('one', 'two', 'three', 'four', 'five'));
$Savant2->assign($values);
$Savant2->assign('valid', $valid);
$Savant2->display('form2.tpl.php');
?>