コード例 #1
0
ファイル: form_example.php プロジェクト: johnulist/library
<?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>
コード例 #2
0
ファイル: test_form_js.php プロジェクト: yehchge/library
<?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 {
    $input = new jream\Form();
    $input->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($input->get());
    $input->submit();
} catch (jream\Exception $e) {
    $z = $e->fetchArray();
    jream\Output::error($z);
}