<?php /** * @author Jesse Boyer <*****@*****.**> * @copyright Copyright (C), 2011-12 Jesse Boyer * @license GNU General Public License 3 (http://www.gnu.org/licenses/) * Refer to the LICENSE file distributed within the package. * * @link http://jream.com */ require_once '../jream/autoload.php'; new jream\Autoload('../jream/'); if (isset($_REQUEST['run'])) { try { $form = new jream\Form(); $form->post('name')->post('agree')->format('checkbox')->post('box')->validate('length', array(1, 25)); $form->submit(); $data = $form->get(); print_r($data); } catch (Exception $e) { echo $e->getMessage(); } } ?> <form action="?run" method="post"> <input type="text" name="name" value="Jesse" /> <input type="checkbox" name="agree" /> <input type="text" name="box" /> <input type="submit" /> </form>
<?php /** * @author Jesse Boyer <*****@*****.**> * @copyright Copyright (C), 2011-12 Jesse Boyer * @license GNU General Public License 3 (http://www.gnu.org/licenses/) * Refer to the LICENSE file distributed within the package. * * @link http://jream.com */ require_once '../../jream/autoload.php'; new jream\Autoload('../../jream/'); // For some JS money money money... try { $form = new jream\Form(); $form->post('name', true)->validate('maxlength', 4)->error('This is a custom error message')->post('age', true)->validate('eq', 12)->error('So this is not matching!')->post('gender', true)->validate('eq', 'f'); //print_r($form->get()); $form->submit(); } catch (jream\Exception $e) { $z = $e->getArray(); jream\Output::error($z); }
print_r($form->get()); } catch (Exception $e) { echo $e->getMessage(); } echo '<hr />'; /** * Negative Cases */ try { $form = new jream\Form(array('name' => 'Jesse', 'age' => 25)); $form->post('name')->validate('minlength', 5)->post('age')->validate('greaterthan', 24); $form->submit(); } catch (Exception $e) { echo $e->getMessage() . '<br />'; } try { $form = new jream\Form(array('name' => 'Jesse', 'age' => 25, 'gender' => 'm')); $form->post('name')->validate('maxlength', 4)->error('This is a custom error message')->post('age')->validate('agemin', 12)->post('gender')->validate('eq', 'f'); $form->submit(); } catch (Exception $e) { echo $e->getMessage() . '<br />'; } echo '<hr />'; // For some JS money money money... try { $form = new jream\Form(array('name' => 'Jesse', 'age' => 25, 'gender' => 'm')); $form->post('name')->validate('maxlength', 4)->error('This is a custom error message')->post('age')->validate('eq', 12)->post('gender')->validate('eq', 'f'); $form->submit(); } catch (jream\Exception $e) { $z = $e->getArray(); }
/** * @author Jesse Boyer <*****@*****.**> * @copyright Copyright (C), 2011-12 Jesse Boyer * @license GNU General Public License 3 (http://www.gnu.org/licenses/) * Refer to the LICENSE file distributed within the package. * * @link http://jream.com */ require_once '../jream/autoload.php'; new jream\Autoload('../jream/'); echo '<pre>'; if (isset($_REQUEST['run'])) { try { $form = new jream\Form(); $form->post('title', true)->validate('minlength', 2)->file('uploadHere', 'uploaded/', 'custom_name', false, true); $form->submit(); echo 'Got beyond the form'; } catch (Exception $e) { echo '<b>Error: ' . $e->getMessage() . '</b>'; } echo '<b>Debug Form</b>'; $form->debug(); } echo '</pre>'; ?> <form method="post" action="?run" enctype="multipart/form-data"> Title: <input type="text" name="title" /><br /> <input type="file" name="uploadHere" /><br /> <input type="submit" />