Initial commit
This commit is contained in:
76
vendor/stefangabos/zebra_form/examples/includes/contact-custom.php
vendored
Normal file
76
vendor/stefangabos/zebra_form/examples/includes/contact-custom.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<h2>A contact form</h2>
|
||||
|
||||
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
|
||||
|
||||
<p>Check the "Template source" tab to see how it's done!</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/user.png'));
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/letter.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
|
||||
|
||||
// "website"
|
||||
$form->add('label', 'label_website', 'website', 'Your website:');
|
||||
$obj = $form->add('text', 'website', '', array('style' => 'width: 400px', 'data-prefix' => 'http://'));
|
||||
$obj->set_rule(array(
|
||||
'url' => array(true, 'error', 'Invalid URL specified!'),
|
||||
));
|
||||
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
|
||||
|
||||
// "subject"
|
||||
$form->add('label', 'label_subject', 'subject', 'Subject');
|
||||
$obj = $form->add('text', 'subject', '', array('style' => 'width: 400px', 'data-prefix' => 'img:public/images/comment.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Subject is required!')
|
||||
));
|
||||
|
||||
// "message"
|
||||
$form->add('label', 'label_message', 'message', 'Message:');
|
||||
$obj = $form->add('textarea', 'message');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Message is required!'),
|
||||
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('includes/custom-templates/contact.php');
|
||||
|
||||
?>
|
||||
74
vendor/stefangabos/zebra_form/examples/includes/contact-horizontal.php
vendored
Normal file
74
vendor/stefangabos/zebra_form/examples/includes/contact-horizontal.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<h2>A contact form</h2>
|
||||
|
||||
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png'));
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
|
||||
|
||||
// "website"
|
||||
$form->add('label', 'label_website', 'website', 'Your website:');
|
||||
$obj = $form->add('text', 'website', '', array('data-prefix' => 'http://'));
|
||||
$obj->set_rule(array(
|
||||
'url' => array(true, 'error', 'Invalid URL specified!'),
|
||||
));
|
||||
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
|
||||
|
||||
// "subject"
|
||||
$form->add('label', 'label_subject', 'subject', 'Subject');
|
||||
$obj = $form->add('text', 'subject', '', array('data-prefix' => 'img:public/images/comment.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Subject is required!')
|
||||
));
|
||||
|
||||
// "message"
|
||||
$form->add('label', 'label_message', 'message', 'Message:');
|
||||
$obj = $form->add('textarea', 'message');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Message is required!'),
|
||||
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btn_submit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('*horizontal');
|
||||
|
||||
?>
|
||||
74
vendor/stefangabos/zebra_form/examples/includes/contact-vertical.php
vendored
Normal file
74
vendor/stefangabos/zebra_form/examples/includes/contact-vertical.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<h2>A contact form</h2>
|
||||
|
||||
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png'));
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
|
||||
|
||||
// "website"
|
||||
$form->add('label', 'label_website', 'website', 'Your website:');
|
||||
$obj = $form->add('text', 'website', '', array('data-prefix' => 'http://'));
|
||||
$obj->set_rule(array(
|
||||
'url' => array(true, 'error', 'Invalid URL specified!'),
|
||||
));
|
||||
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
|
||||
|
||||
// "subject"
|
||||
$form->add('label', 'label_subject', 'subject', 'Subject');
|
||||
$obj = $form->add('text', 'subject', '', array('style' => 'width:400px', 'data-prefix' => 'img:public/images/comment.png'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Subject is required!')
|
||||
));
|
||||
|
||||
// "message"
|
||||
$form->add('label', 'label_message', 'message', 'Message:');
|
||||
$obj = $form->add('textarea', 'message');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Message is required!'),
|
||||
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true)
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
36
vendor/stefangabos/zebra_form/examples/includes/container-html/container.html
vendored
Normal file
36
vendor/stefangabos/zebra_form/examples/includes/container-html/container.html
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<!-- must be in strict mode! -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Zebra_Form Example</title>
|
||||
|
||||
<!-- load Zebra_Form's stylesheet file -->
|
||||
<link rel="stylesheet" href="path/to/zebra_form.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--
|
||||
|
||||
the content from the "PHP Source" tab goes here
|
||||
|
||||
-->
|
||||
|
||||
<!-- we're loading the JavaScript files at the bottom of the page so we don't delay page rendering -->
|
||||
|
||||
<!-- try to load jQuery from CDN server and fallback to local source if not available -->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="path/to/jquery-1.9.1.min.js"><\/script>')</script>
|
||||
|
||||
<!-- load Zebra_Form's JavaScript file -->
|
||||
<script src="path/to/zebra_form.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
27
vendor/stefangabos/zebra_form/examples/includes/custom-templates/contact.php
vendored
Normal file
27
vendor/stefangabos/zebra_form/examples/includes/custom-templates/contact.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// don't forget about this for custom templates, or errors will not show for server-side validation
|
||||
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
|
||||
// $error is the name of the variable used with the set_rule method
|
||||
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
|
||||
?>
|
||||
|
||||
<!-- elements are grouped in "rows" -->
|
||||
<div class="row">
|
||||
|
||||
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
|
||||
<div class="cell"><?php echo $label_name . $name?></div>
|
||||
<div class="cell"><?php echo $label_email . $email . $note_email?></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- notice the "even" class which is used to highlight even rows differently
|
||||
from the odd rows -->
|
||||
<div class="row even"><?php echo $label_website . $website . $note_website?></div>
|
||||
|
||||
<div class="row"><?php echo $label_subject . $subject?></div>
|
||||
|
||||
<div class="row even"><?php echo $label_message . $message?></div>
|
||||
|
||||
<!-- the submit button goes in the last row; also, notice the "last" class which
|
||||
removes the bottom border which is otherwise present for any row -->
|
||||
<div class="row last"><?php echo $btnsubmit?></div>
|
||||
28
vendor/stefangabos/zebra_form/examples/includes/custom-templates/divs-login.php
vendored
Normal file
28
vendor/stefangabos/zebra_form/examples/includes/custom-templates/divs-login.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// don't forget about this for custom templates, or errors will not show for server-side validation
|
||||
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
|
||||
// $error is the name of the variable used with the set_rule method
|
||||
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
|
||||
?>
|
||||
|
||||
<!-- elements are grouped in "rows" -->
|
||||
<div class="row">
|
||||
|
||||
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
|
||||
<div class="cell"><?php echo $label_email . $email?></div>
|
||||
<div class="cell"><?php echo $label_password . $password?></div>
|
||||
|
||||
<div class="clear" style="margin-bottom:10px"></div>
|
||||
|
||||
<!-- on the same row, but beneath the email and the password fields,
|
||||
we place the "remember me" checkbox and attached label -->
|
||||
<div class="cell"><?php echo $remember_me_yes?></div>
|
||||
<div class="cell"><?php echo $label_remember_me_yes?></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- the submit button goes in the last row; notice the "even" class which
|
||||
is used to highlight even rows differently from the odd rows; also, notice
|
||||
the "last" class which removes the bottom border which is otherwise present
|
||||
for any row -->
|
||||
<div class="row even last"><?php echo $btnsubmit?></div>
|
||||
73
vendor/stefangabos/zebra_form/examples/includes/custom-templates/example1-dependencies.php
vendored
Normal file
73
vendor/stefangabos/zebra_form/examples/includes/custom-templates/example1-dependencies.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<!--
|
||||
in reality you'd have this in an external stylesheet;
|
||||
i am using it like this for the sake of the example
|
||||
-->
|
||||
<style type="text/css">
|
||||
.Zebra_Form .optional { padding: 10px 50px; display: none }
|
||||
</style>
|
||||
|
||||
<!--
|
||||
again, in reality you'd have this in an external JavaScript file;
|
||||
i am using it like this for the sake of the example
|
||||
-->
|
||||
<script type="text/javascript">
|
||||
var mycallback = function(value, segment) {
|
||||
$segment = $('.optional' + segment);
|
||||
if (value) $segment.show();
|
||||
else $segment.hide();
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''))?>
|
||||
|
||||
<div class="row">
|
||||
<?php echo $label_name . $name?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<?php echo $label_notifications?>
|
||||
<div class="cell"><?php echo $notifications_yes?></div>
|
||||
<div class="cell"><?php echo $label_notifications_yes?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="optional optional1">
|
||||
|
||||
<?php echo $label_method?>
|
||||
<div class="cell"><?php echo $method_email?></div>
|
||||
<div class="cell"><?php echo $label_method_email?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="optional optional2">
|
||||
<?php echo $label_email . $email . $note_email?>
|
||||
</div>
|
||||
|
||||
<div class="cell"><?php echo $method_phone?></div>
|
||||
<div class="cell"><?php echo $label_method_phone?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="optional optional3">
|
||||
<?php echo $label_phone . $phone . $note_phone?>
|
||||
</div>
|
||||
|
||||
<div class="cell"><?php echo $method_post?></div>
|
||||
<div class="cell"><?php echo $label_method_post?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="optional optional4">
|
||||
<?php echo $label_post . $post . $note_post?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="cell"><?php echo $notifications_no?></div>
|
||||
<div class="cell"><?php echo $label_notifications_no?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="optional optional5">
|
||||
<?php echo $label_why . $why?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row last"><?php echo $btnsubmit?></div>
|
||||
15
vendor/stefangabos/zebra_form/examples/includes/custom-templates/example2-dependencies.php
vendored
Normal file
15
vendor/stefangabos/zebra_form/examples/includes/custom-templates/example2-dependencies.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''))?>
|
||||
|
||||
<div class="row">
|
||||
<div class="cell"><?php echo $label_name . $name?></div>
|
||||
<div class="cell"><?php echo $label_surname . $surname?></div>
|
||||
</div>
|
||||
|
||||
<div class="row even">
|
||||
<h6><strong>Add new person</strong></h6><br>
|
||||
<div class="cell"><?php echo $label_add_name . $add_name?></div>
|
||||
<div class="cell"><?php echo $label_add_surname . $add_surname?></div>
|
||||
<div class="cell"><br><?php echo $btnadd?></div>
|
||||
</div>
|
||||
|
||||
<div class="row last"><?php echo $btnsubmit?></div>
|
||||
32
vendor/stefangabos/zebra_form/examples/includes/custom-templates/registration.php
vendored
Normal file
32
vendor/stefangabos/zebra_form/examples/includes/custom-templates/registration.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// don't forget about this for custom templates, or errors will not show for server-side validation
|
||||
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
|
||||
// $error is the name of the variable used with the set_rule method
|
||||
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
|
||||
?>
|
||||
|
||||
<!-- elements are grouped in "rows" -->
|
||||
<div class="row">
|
||||
|
||||
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
|
||||
<div class="cell"><?php echo $label_firstname . $firstname?></div>
|
||||
<div class="cell"><?php echo $label_lastname . $lastname?></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- notice the "even" class which is used to highlight even rows differently
|
||||
from the odd rows -->
|
||||
<div class="row even"><?php echo $label_email . $email . $note_email?></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="cell"><?php echo $label_password . $password . $note_password?></div>
|
||||
<div class="cell"><?php echo $label_confirm_password . $confirm_password?></div>
|
||||
</div>
|
||||
|
||||
<div class="row even">
|
||||
<?php echo $captcha_image . $label_captcha_code . $captcha_code . $note_captcha?>
|
||||
</div>
|
||||
|
||||
<!-- the submit button goes in the last row; also, notice the "last" class which
|
||||
removes the bottom border which is otherwise present for any row -->
|
||||
<div class="row even last"><?php echo $btnsubmit?></div>
|
||||
72
vendor/stefangabos/zebra_form/examples/includes/custom-templates/reservation.php
vendored
Normal file
72
vendor/stefangabos/zebra_form/examples/includes/custom-templates/reservation.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// don't forget about this for custom templates, or errors will not show for server-side validation
|
||||
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
|
||||
// $error is the name of the variable used with the set_rule method
|
||||
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
|
||||
?>
|
||||
|
||||
<!-- elements are grouped in "rows" -->
|
||||
<div class="row">
|
||||
|
||||
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
|
||||
<div class="cell"><?php echo $label_name . $name?></div>
|
||||
<div class="cell"><?php echo $label_email . $email?></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- notice the "even" class which is used to highlight even rows differently
|
||||
from the odd rows -->
|
||||
<div class="row even">
|
||||
<?php echo $label_department . $department . $department_other?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="cell">
|
||||
|
||||
<?php echo $label_room?>
|
||||
|
||||
<!-- this is the preffered way of displaying checkboxes and
|
||||
radio buttons and their associated label -->
|
||||
<div class="cell"><?php echo $room_A?></div>
|
||||
<div class="cell"><?php echo $label_room_A?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="cell"><?php echo $room_B?></div>
|
||||
<div class="cell"><?php echo $label_room_B?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="cell"><?php echo $room_C?></div>
|
||||
<div class="cell"><?php echo $label_room_C?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="cell" style="margin-left: 20px">
|
||||
|
||||
<?php echo $label_extra?>
|
||||
|
||||
<div class="cell"><?php echo $extra_flipchard?></div>
|
||||
<div class="cell"><?php echo $label_extra_flipchard?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="cell"><?php echo $extra_plasma?></div>
|
||||
<div class="cell"><?php echo $label_extra_plasma?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="cell"><?php echo $extra_beverages?></div>
|
||||
<div class="cell"><?php echo $label_extra_beverages?></div>
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row even">
|
||||
<div class="cell"><?php echo $label_date . $date?></div>
|
||||
<div class="cell" style="margin-left: 10px"><?php echo $label_time . $time?></div>
|
||||
</div>
|
||||
|
||||
<!-- the submit button goes in the last row; also, notice the "last" class which
|
||||
removes the bottom border which is otherwise present for any row -->
|
||||
<div class="row last"><?php echo $btnsubmit?></div>
|
||||
45
vendor/stefangabos/zebra_form/examples/includes/custom-templates/tables-login.php
vendored
Normal file
45
vendor/stefangabos/zebra_form/examples/includes/custom-templates/tables-login.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// don't forget about this for custom templates, or errors will not show for server-side validation
|
||||
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
|
||||
// $error is the name of the variable used with the set_rule method
|
||||
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
|
||||
?>
|
||||
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
|
||||
<!-- elements are grouped in "rows" -->
|
||||
<tr class="row">
|
||||
<td><?php echo $label_email?></td>
|
||||
<td><?php echo $email?></td>
|
||||
</tr>
|
||||
|
||||
<!-- notice the "even" class which is used to highlight even rows differently
|
||||
from the odd rows -->
|
||||
<tr class="row even">
|
||||
<td><?php echo $label_password?></td>
|
||||
<td><?php echo $password?></td>
|
||||
</tr>
|
||||
|
||||
<tr class="row">
|
||||
<td></td>
|
||||
<td>
|
||||
|
||||
<!-- this is the preffered way of displaying checkboxes and
|
||||
radio buttons and their associated label -->
|
||||
<div class="cell"><?php echo $remember_me_yes?></div>
|
||||
<div class="cell"><?php echo $label_remember_me_yes?></div>
|
||||
|
||||
<!-- once we're done with "cells" we *must* place a "clear" div -->
|
||||
<div class="clear"></div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- the submit button goes in the last row; also, notice the "last" class which
|
||||
removes the bottom border which is otherwise present for any row -->
|
||||
<tr class="row even last">
|
||||
<td></td>
|
||||
<td><?php echo $btnsubmit?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
106
vendor/stefangabos/zebra_form/examples/includes/dependencies-example1-custom.php
vendored
Normal file
106
vendor/stefangabos/zebra_form/examples/includes/dependencies-example1-custom.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<h2>Dependencies</h2>
|
||||
|
||||
<p>Showcasing how elements can be validated only if other elements meet certain conditions and how callback functions for the "dependencies" rule work.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// add the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name');
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Name is required!'),
|
||||
));
|
||||
|
||||
// "notifications"
|
||||
$form->add('label', 'label_notifications', 'notifications', 'Would you like to be informed about promotional offers?');
|
||||
$obj = $form->add('radios', 'notifications', array(
|
||||
'yes' => 'Yes',
|
||||
'no' => 'No',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Please select an answer!'),
|
||||
));
|
||||
|
||||
// "method"
|
||||
$form->add('label', 'label_method', 'method', 'Please specify how you would like to be notified about promotional offers:');
|
||||
$obj = $form->add('checkboxes', 'method[]', array(
|
||||
'email' => 'By e-mail',
|
||||
'phone' => 'By phone',
|
||||
'post' => 'By land mail',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Please specify how you would like to be notified about promotional offers!'),
|
||||
'dependencies' => array(array(
|
||||
'notifications' => 'yes',
|
||||
// whenever the value of "notification" changes, call this function and pass as second argument the value "1"
|
||||
), 'mycallback, 1'),
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
'dependencies' => array(array(
|
||||
'method' => 'email',
|
||||
), 'mycallback, 2'),
|
||||
));
|
||||
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
|
||||
|
||||
// "phone"
|
||||
$form->add('label', 'label_phone', 'phone', 'Your telephone number:');
|
||||
$obj = $form->add('text', 'phone');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Phone number is required!'),
|
||||
'digits' => array('', 'error', 'Phone number must contain only digits!'),
|
||||
'dependencies' => array(array(
|
||||
'method' => 'phone',
|
||||
), 'mycallback, 3'),
|
||||
));
|
||||
$form->add('note', 'note_phone', 'phone', 'Enter your phone number using digits only');
|
||||
|
||||
// "post"
|
||||
$form->add('label', 'label_post', 'post', 'Your postal address:');
|
||||
$obj = $form->add('text', 'post');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Postal address is required!'),
|
||||
'dependencies' => array(array(
|
||||
'method' => 'post',
|
||||
), 'mycallback, 4'),
|
||||
));
|
||||
$form->add('note', 'note_post', 'post', 'Enter the address where the notifications about promotional offers should be delivered');
|
||||
|
||||
// "why"
|
||||
$form->add('label', 'label_why', 'why', 'Please tell us why:');
|
||||
$obj = $form->add('textarea', 'why');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Please leave us a message!'),
|
||||
'dependencies' => array(array(
|
||||
'notifications' => 'no',
|
||||
), 'mycallback, 5'),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
$form->render('includes/custom-templates/example1-dependencies.php');
|
||||
|
||||
?>
|
||||
75
vendor/stefangabos/zebra_form/examples/includes/dependencies-example2-custom.php
vendored
Normal file
75
vendor/stefangabos/zebra_form/examples/includes/dependencies-example2-custom.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<h2>Dependencies</h2>
|
||||
|
||||
<p>Notice how the elements from the "Add new person" section are validated *only* when the "Add new" button is clicked</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// add the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Name');
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Name is required!'),
|
||||
));
|
||||
|
||||
// add the "surname" element
|
||||
$form->add('label', 'label_surname', 'surname', 'Surname');
|
||||
$obj = $form->add('text', 'surname');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Surname is required!'),
|
||||
));
|
||||
|
||||
// elements for adding a new person
|
||||
|
||||
// add the "name" element
|
||||
$form->add('label', 'label_add_name', 'add_name', 'Name');
|
||||
$obj = $form->add('text', 'add_name');
|
||||
|
||||
// set rules
|
||||
// validate *only* if the "Add new" button is clicked
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Name is required!'),
|
||||
'dependencies' => array(
|
||||
'btnadd' => 'click',
|
||||
),
|
||||
));
|
||||
|
||||
// add the "surname" element
|
||||
$form->add('label', 'label_add_surname', 'add_surname', 'Surame');
|
||||
$obj = $form->add('text', 'add_surname');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Surname is required!'),
|
||||
'dependencies' => array(
|
||||
'btnadd' => 'click',
|
||||
),
|
||||
));
|
||||
|
||||
// "add"
|
||||
$form->add('submit', 'btnadd', 'Add new');
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Finish');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
$form->render('includes/custom-templates/example2-dependencies.php');
|
||||
|
||||
?>
|
||||
52
vendor/stefangabos/zebra_form/examples/includes/fileupload-basic-image-vertical.php
vendored
Normal file
52
vendor/stefangabos/zebra_form/examples/includes/fileupload-basic-image-vertical.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<h2>Basic image upload</h2>
|
||||
|
||||
<p>We're checking for file types </p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "file" element
|
||||
$form->add('label', 'label_file', 'file', 'Upload an image');
|
||||
|
||||
// add the "file" element
|
||||
$obj = $form->add('file', 'file');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'An image is required!'),
|
||||
'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!<br>Check that the "tmp" folder exists inside the "examples" folder and that it is writable'),
|
||||
|
||||
// notice how we use the "image" rule instead of the "filetype" rule (used in previous example);
|
||||
// the "image" rule does a thorough checking aimed specially for images
|
||||
'image' => array('error', 'File must be a jpg, png or gif image!'),
|
||||
'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'),
|
||||
|
||||
));
|
||||
|
||||
// attach a note
|
||||
$form->add('note', 'note_file', 'file', 'File must have the .jpg, .jpeg, png or .gif extension, and no more than 100Kb!');
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// validate the form
|
||||
if ($form->validate()) {
|
||||
|
||||
// do stuff here
|
||||
print_r('<pre>');
|
||||
print_r($form->file_upload);
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
// auto generate output, labels above form elements
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
49
vendor/stefangabos/zebra_form/examples/includes/fileupload-basic-vertical.php
vendored
Normal file
49
vendor/stefangabos/zebra_form/examples/includes/fileupload-basic-vertical.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<h2>Basic file upload</h2>
|
||||
|
||||
<p>Once you upload the file, don't forget to look into the "tmp" folder inside the "examples" folder for the result.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "file" element
|
||||
$form->add('label', 'label_file', 'file', 'Upload Microsoft Word document');
|
||||
|
||||
// add the "file" element
|
||||
$obj = $form->add('file', 'file');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'A Microsoft Word document is required!'),
|
||||
'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!<br>Check that the "tmp" folder exists inside the "examples" folder and that it is writable'),
|
||||
'filetype' => array('doc, docx', 'error', 'File must be a Microsoft Word document!'),
|
||||
'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'),
|
||||
|
||||
));
|
||||
|
||||
// attach a note
|
||||
$form->add('note', 'note_file', 'file', 'File must have the .doc or .docx extension, and no more than 100Kb!');
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// validate the form
|
||||
if ($form->validate()) {
|
||||
|
||||
// do stuff here
|
||||
print_r('<pre>');
|
||||
print_r($form->file_upload);
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
// auto generate output, labels above form elements
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
62
vendor/stefangabos/zebra_form/examples/includes/login-divs-custom.php
vendored
Normal file
62
vendor/stefangabos/zebra_form/examples/includes/login-divs-custom.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<h2>A login form</h2>
|
||||
|
||||
<p>In this demo we're creating a custom template using only divs; this is suitable for creating "vertical" templates (when
|
||||
a control's label is above the control), but when we want some elements to be side-by-side. Don't forget to check the
|
||||
"Template source" tab to see how it's done.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "email" element
|
||||
$form->add('label', 'label_email', 'email', 'Email');
|
||||
|
||||
// add the "email" element
|
||||
$obj = $form->add('text', 'email');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
|
||||
));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Password');
|
||||
|
||||
$obj = $form->add('password', 'password');
|
||||
|
||||
$obj->set_rule(array(
|
||||
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
|
||||
|
||||
));
|
||||
|
||||
// "remember me"
|
||||
$form->add('checkbox', 'remember_me', 'yes');
|
||||
|
||||
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('includes/custom-templates/divs-login.php');
|
||||
|
||||
?>
|
||||
53
vendor/stefangabos/zebra_form/examples/includes/login-horizontal.php
vendored
Normal file
53
vendor/stefangabos/zebra_form/examples/includes/login-horizontal.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<h2>A login form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "email" element
|
||||
$form->add('label', 'label_email', 'email', 'Email');
|
||||
|
||||
// add the "email" element
|
||||
$obj = $form->add('text', 'email');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
|
||||
));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Password');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
|
||||
));
|
||||
|
||||
// "remember me"
|
||||
$form->add('checkbox', 'remember_me', 'yes');
|
||||
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('*horizontal');
|
||||
|
||||
?>
|
||||
53
vendor/stefangabos/zebra_form/examples/includes/login-labels-inside.php
vendored
Normal file
53
vendor/stefangabos/zebra_form/examples/includes/login-labels-inside.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<h2>A login form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "email" element
|
||||
$form->add('label', 'label_email', 'email', 'Email address', array('inside' => true));
|
||||
|
||||
// add the "email" element
|
||||
$obj = $form->add('text', 'email');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
|
||||
));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Password', array('inside' => true));
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
|
||||
));
|
||||
|
||||
// "remember me"
|
||||
$form->add('checkbox', 'remember_me', 'yes');
|
||||
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
56
vendor/stefangabos/zebra_form/examples/includes/login-tables-custom.php
vendored
Normal file
56
vendor/stefangabos/zebra_form/examples/includes/login-tables-custom.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<h2>A login form</h2>
|
||||
|
||||
<p>In this demo we're creating a custom template using tables; this is suitable for creating "horizontal" templates (when
|
||||
a control's label is to the left of the control). Don't forget to check the "Template source" tab to see how it's done.</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "email" element
|
||||
$form->add('label', 'label_email', 'email', 'Email');
|
||||
|
||||
// add the "email" element
|
||||
$obj = $form->add('text', 'email');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
|
||||
));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Password');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
|
||||
));
|
||||
|
||||
// "remember me"
|
||||
$form->add('checkbox', 'remember_me', 'yes');
|
||||
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('includes/custom-templates/tables-login.php');
|
||||
|
||||
?>
|
||||
53
vendor/stefangabos/zebra_form/examples/includes/login-vertical.php
vendored
Normal file
53
vendor/stefangabos/zebra_form/examples/includes/login-vertical.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<h2>A login form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "email" element
|
||||
$form->add('label', 'label_email', 'email', 'Email');
|
||||
|
||||
// add the "email" element
|
||||
$obj = $form->add('text', 'email');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
|
||||
));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Password');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
|
||||
));
|
||||
|
||||
// "remember me"
|
||||
$form->add('checkbox', 'remember_me', 'yes');
|
||||
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// auto generate output, labels above form elements
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
88
vendor/stefangabos/zebra_form/examples/includes/registration-custom.php
vendored
Normal file
88
vendor/stefangabos/zebra_form/examples/includes/registration-custom.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<h2>A registration form</h2>
|
||||
|
||||
<p>Check the "Template source" tab to see how it's done!</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "first name" element
|
||||
$form->add('label', 'label_firstname', 'firstname', 'First name:');
|
||||
|
||||
// add the "first name" element
|
||||
$obj = $form->add('text', 'firstname');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'First name is required!'),
|
||||
|
||||
));
|
||||
|
||||
// "last name"
|
||||
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
|
||||
$obj = $form->add('text', 'lastname');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Last name is required!')
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!')
|
||||
));
|
||||
|
||||
// attach a note to the email element
|
||||
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
|
||||
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Choose a password:');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
|
||||
));
|
||||
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.', array('style' => 'width: 180px'));
|
||||
|
||||
// "confirm password"
|
||||
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
|
||||
$obj = $form->add('password', 'confirm_password');
|
||||
$obj->set_rule(array(
|
||||
'compare' => array('password', 'error', 'Password not confirmed correctly!')
|
||||
));
|
||||
|
||||
// "captcha"
|
||||
$form->add('captcha', 'captcha_image', 'captcha_code');
|
||||
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
|
||||
$obj = $form->add('text', 'captcha_code');
|
||||
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
|
||||
out from the other characters', array('style'=>'width: 200px'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Enter the characters from the image above!'),
|
||||
'captcha' => array('error', 'Characters from image entered incorrectly!')
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('includes/custom-templates/registration.php');
|
||||
|
||||
?>
|
||||
86
vendor/stefangabos/zebra_form/examples/includes/registration-horizontal.php
vendored
Normal file
86
vendor/stefangabos/zebra_form/examples/includes/registration-horizontal.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<h2>A registration form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "first name" element
|
||||
$form->add('label', 'label_firstname', 'firstname', 'First name:');
|
||||
|
||||
// add the "first name" element
|
||||
$obj = $form->add('text', 'firstname');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'First name is required!'),
|
||||
|
||||
));
|
||||
|
||||
// "last name"
|
||||
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
|
||||
$obj = $form->add('text', 'lastname');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Last name is required!')
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!')
|
||||
));
|
||||
|
||||
// attach a note to the email element
|
||||
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
|
||||
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Choose a password:');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
|
||||
));
|
||||
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.');
|
||||
|
||||
// "confirm password"
|
||||
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
|
||||
$obj = $form->add('password', 'confirm_password');
|
||||
$obj->set_rule(array(
|
||||
'compare' => array('password', 'error', 'Password not confirmed correctly!')
|
||||
));
|
||||
|
||||
// "captcha"
|
||||
$form->add('captcha', 'captcha_image', 'captcha_code');
|
||||
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
|
||||
$obj = $form->add('text', 'captcha_code');
|
||||
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
|
||||
out from the other characters', array('style'=>'width: 200px'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Enter the characters from the image above!'),
|
||||
'captcha' => array('error', 'Characters from image entered incorrectly!')
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('*horizontal');
|
||||
|
||||
?>
|
||||
86
vendor/stefangabos/zebra_form/examples/includes/registration-vertical.php
vendored
Normal file
86
vendor/stefangabos/zebra_form/examples/includes/registration-vertical.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<h2>A registration form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
|
||||
|
||||
// the label for the "first name" element
|
||||
$form->add('label', 'label_firstname', 'firstname', 'First name:');
|
||||
|
||||
// add the "first name" element
|
||||
$obj = $form->add('text', 'firstname');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'First name is required!'),
|
||||
|
||||
));
|
||||
|
||||
// "last name"
|
||||
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
|
||||
$obj = $form->add('text', 'lastname');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Last name is required!')
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!')
|
||||
));
|
||||
|
||||
// attach a note to the email element
|
||||
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
|
||||
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
|
||||
|
||||
// "password"
|
||||
$form->add('label', 'label_password', 'password', 'Choose a password:');
|
||||
$obj = $form->add('password', 'password');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Password is required!'),
|
||||
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
|
||||
));
|
||||
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.');
|
||||
|
||||
// "confirm password"
|
||||
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
|
||||
$obj = $form->add('password', 'confirm_password');
|
||||
$obj->set_rule(array(
|
||||
'compare' => array('password', 'error', 'Password not confirmed correctly!')
|
||||
));
|
||||
|
||||
// "captcha"
|
||||
$form->add('captcha', 'captcha_image', 'captcha_code');
|
||||
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
|
||||
$obj = $form->add('text', 'captcha_code');
|
||||
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
|
||||
out from the other characters', array('style'=>'width: 200px'));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Enter the characters from the image above!'),
|
||||
'captcha' => array('error', 'Characters from image entered incorrectly!')
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
116
vendor/stefangabos/zebra_form/examples/includes/reservation-autofill-vertical.php
vendored
Normal file
116
vendor/stefangabos/zebra_form/examples/includes/reservation-autofill-vertical.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<h2>A meeting room reservation form</h2>
|
||||
|
||||
<p>All fields will be automatically filled with random values - very useful for when debugging forms. The random values will obey the rules set for each element!</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// auto-fill fields with random values
|
||||
// very useful for when debugging forms
|
||||
$form->auto_fill();
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
|
||||
// "department"
|
||||
$form->add('label', 'label_department', 'department', 'Department:');
|
||||
$obj = $form->add('select', 'department', '', array('other' => true));
|
||||
$obj->add_options(array(
|
||||
'Marketing',
|
||||
'Operations',
|
||||
'Customer Service',
|
||||
'Human Resources',
|
||||
'Sales Department',
|
||||
'Accounting Department',
|
||||
'Legal Department',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Department is required!')
|
||||
));
|
||||
|
||||
// "room"
|
||||
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
|
||||
$obj = $form->add('radios', 'room', array(
|
||||
'A' => 'Room A',
|
||||
'B' => 'Room B',
|
||||
'C' => 'Room C',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Room selection is required!')
|
||||
));
|
||||
|
||||
// "extra"
|
||||
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
|
||||
$obj = $form->add('checkboxes', 'extra[]', array(
|
||||
'flipchard' => 'Flipchard and pens',
|
||||
'plasma' => 'Plasma TV screen',
|
||||
'beverages' => 'Coffee, tea and mineral water',
|
||||
));
|
||||
|
||||
// "date"
|
||||
$form->add('label', 'label_date', 'date', 'Reservation date');
|
||||
$date = $form->add('date', 'date');
|
||||
$date->set_rule(array(
|
||||
'required' => array('error', 'Date is required!'),
|
||||
'date' => array('error', 'Date is invalid!'),
|
||||
));
|
||||
|
||||
// date format
|
||||
// don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used
|
||||
// in a database or with PHP's strtotime function!
|
||||
$date->format('M d, Y');
|
||||
|
||||
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
|
||||
|
||||
// "time"
|
||||
$form->add('label', 'label_time', 'time', 'Reservation time :');
|
||||
$obj = $form->add('time', 'time', '', array(
|
||||
'format' => 'hm',
|
||||
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
|
||||
'minutes' => array(0, 30),
|
||||
));
|
||||
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Time is required!'),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
110
vendor/stefangabos/zebra_form/examples/includes/reservation-custom.php
vendored
Normal file
110
vendor/stefangabos/zebra_form/examples/includes/reservation-custom.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<h2>A meeting room reservation form</h2>
|
||||
|
||||
<p>Check the "Template source" tab to see how it's done!</p>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
|
||||
// "department"
|
||||
$form->add('label', 'label_department', 'department', 'Department:');
|
||||
$obj = $form->add('select', 'department', '', array('other' => true));
|
||||
$obj->add_options(array(
|
||||
'Marketing',
|
||||
'Operations',
|
||||
'Customer Service',
|
||||
'Human Resources',
|
||||
'Sales Department',
|
||||
'Accounting Department',
|
||||
'Legal Department',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Department is required!')
|
||||
));
|
||||
|
||||
// "room"
|
||||
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
|
||||
$obj = $form->add('radios', 'room', array(
|
||||
'A' => 'Room A',
|
||||
'B' => 'Room B',
|
||||
'C' => 'Room C',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Room selection is required!')
|
||||
));
|
||||
|
||||
// "extra"
|
||||
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
|
||||
$obj = $form->add('checkboxes', 'extra[]', array(
|
||||
'flipchard' => 'Flipchard and pens',
|
||||
'plasma' => 'Plasma TV screen',
|
||||
'beverages' => 'Coffee, tea and mineral water',
|
||||
));
|
||||
|
||||
// "date"
|
||||
$form->add('label', 'label_date', 'date', 'Reservation date');
|
||||
$date = $form->add('date', 'date');
|
||||
$date->set_rule(array(
|
||||
'required' => array('error', 'Date is required!'),
|
||||
'date' => array('error', 'Date is invalid!'),
|
||||
));
|
||||
|
||||
// date format
|
||||
// don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used
|
||||
// in a database or with PHP's strtotime function!
|
||||
$date->format('M d, Y');
|
||||
|
||||
// selectable dates are starting with the current day
|
||||
$date->direction(1);
|
||||
|
||||
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
|
||||
|
||||
// "time"
|
||||
$form->add('label', 'label_time', 'time', 'Reservation time :');
|
||||
$form->add('time', 'time', '', array(
|
||||
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
|
||||
'minutes' => array(0, 30),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('includes/custom-templates/reservation.php');
|
||||
|
||||
?>
|
||||
108
vendor/stefangabos/zebra_form/examples/includes/reservation-horizontal.php
vendored
Normal file
108
vendor/stefangabos/zebra_form/examples/includes/reservation-horizontal.php
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
<h2>A meeting room reservation form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'email' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
|
||||
// "department"
|
||||
$form->add('label', 'label_department', 'department', 'Department:');
|
||||
$obj = $form->add('select', 'department', '', array('other' => true));
|
||||
$obj->add_options(array(
|
||||
'Marketing',
|
||||
'Operations',
|
||||
'Customer Service',
|
||||
'Human Resources',
|
||||
'Sales Department',
|
||||
'Accounting Department',
|
||||
'Legal Department',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Department is required!')
|
||||
));
|
||||
|
||||
// "room"
|
||||
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
|
||||
$obj = $form->add('radios', 'room', array(
|
||||
'A' => 'Room A',
|
||||
'B' => 'Room B',
|
||||
'C' => 'Room C',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Room selection is required!')
|
||||
));
|
||||
|
||||
// "extra"
|
||||
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
|
||||
$obj = $form->add('checkboxes', 'extra[]', array(
|
||||
'flipchard' => 'Flipchard and pens',
|
||||
'plasma' => 'Plasma TV screen',
|
||||
'beverages' => 'Coffee, tea and mineral water',
|
||||
));
|
||||
|
||||
// "date"
|
||||
$form->add('label', 'label_date', 'date', 'Reservation date');
|
||||
$date = $form->add('date', 'date');
|
||||
$date->set_rule(array(
|
||||
'required' => array('error', 'Date is required!'),
|
||||
'date' => array('error', 'Date is invalid!'),
|
||||
));
|
||||
|
||||
// date format
|
||||
// don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used
|
||||
// in a database or with PHP's strtotime function!
|
||||
$date->format('M d, Y');
|
||||
|
||||
// selectable dates are starting with the current day
|
||||
$date->direction(1);
|
||||
|
||||
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
|
||||
|
||||
// "time"
|
||||
$form->add('label', 'label_time', 'time', 'Reservation time :');
|
||||
$form->add('time', 'time', '', array(
|
||||
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
|
||||
'minutes' => array(0, 30),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render('*horizontal');
|
||||
|
||||
?>
|
||||
110
vendor/stefangabos/zebra_form/examples/includes/reservation-vertical.php
vendored
Normal file
110
vendor/stefangabos/zebra_form/examples/includes/reservation-vertical.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<h2>A meeting room reservation form</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// the label for the "name" element
|
||||
$form->add('label', 'label_name', 'name', 'Your name:');
|
||||
|
||||
// add the "name" element
|
||||
$obj = $form->add('text', 'name');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'Name is required!')
|
||||
|
||||
));
|
||||
|
||||
// "email"
|
||||
$form->add('label', 'label_email', 'email', 'Your email address:');
|
||||
$obj = $form->add('text', 'email');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Email is required!'),
|
||||
'emails' => array('error', 'Email address seems to be invalid!'),
|
||||
));
|
||||
|
||||
// "department"
|
||||
$form->add('label', 'label_department', 'department', 'Department:');
|
||||
$obj = $form->add('select', 'department', '', array('other' => true));
|
||||
$obj->add_options(array(
|
||||
'Marketing',
|
||||
'Operations',
|
||||
'Customer Service',
|
||||
'Human Resources',
|
||||
'Sales Department',
|
||||
'Accounting Department',
|
||||
'Legal Department',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Department is required!')
|
||||
));
|
||||
|
||||
// "room"
|
||||
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
|
||||
$obj = $form->add('radios', 'room', array(
|
||||
'A' => 'Room A',
|
||||
'B' => 'Room B',
|
||||
'C' => 'Room C',
|
||||
));
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Room selection is required!')
|
||||
));
|
||||
|
||||
// "extra"
|
||||
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
|
||||
$obj = $form->add('checkboxes', 'extra[]', array(
|
||||
'flipchard' => 'Flipchard and pens',
|
||||
'plasma' => 'Plasma TV screen',
|
||||
'beverages' => 'Coffee, tea and mineral water',
|
||||
));
|
||||
|
||||
// "date"
|
||||
$form->add('label', 'label_date', 'date', 'Reservation date');
|
||||
$date = $form->add('date', 'date');
|
||||
$date->set_rule(array(
|
||||
'required' => array('error', 'Date is required!'),
|
||||
'date' => array('error', 'Date is invalid!'),
|
||||
));
|
||||
|
||||
// date format
|
||||
// don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used
|
||||
// in a database or with PHP's strtotime function!
|
||||
$date->format('M d, Y');
|
||||
|
||||
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
|
||||
|
||||
// "time"
|
||||
$form->add('label', 'label_time', 'time', 'Reservation time :');
|
||||
$obj = $form->add('time', 'time', '', array(
|
||||
'format' => 'hm',
|
||||
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
|
||||
'minutes' => array(0, 30),
|
||||
));
|
||||
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'Time is required!'),
|
||||
));
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
107
vendor/stefangabos/zebra_form/examples/includes/validation-vertical.php
vendored
Normal file
107
vendor/stefangabos/zebra_form/examples/includes/validation-vertical.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<h2>More validation rules</h2>
|
||||
|
||||
<?php
|
||||
|
||||
// include the Zebra_Form class
|
||||
require '../Zebra_Form.php';
|
||||
|
||||
// instantiate a Zebra_Form object
|
||||
$form = new Zebra_Form('form');
|
||||
|
||||
// "alphabet"
|
||||
$form->add('label', 'label_alphabet', 'alphabet', 'Alphabet:');
|
||||
|
||||
$obj = $form->add('text', 'alphabet');
|
||||
|
||||
// set rules
|
||||
$obj->set_rule(array(
|
||||
|
||||
// error messages will be sent to a variable called "error", usable in custom templates
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'alphabet' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z)')
|
||||
|
||||
));
|
||||
|
||||
// attach a note
|
||||
$form->add('note', 'note_alphabet', 'alphabet', 'Accepts only characters from the alphabet (case-insensitive a to z)');
|
||||
|
||||
// "alphanumeric"
|
||||
$form->add('label', 'label_alphanumeric', 'alphanumeric', 'Alphanumeric:');
|
||||
$obj = $form->add('text', 'alphanumeric');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'alphanumeric' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)')
|
||||
));
|
||||
$form->add('note', 'note_alphanumeric', 'alphanumeric', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)');
|
||||
|
||||
// "digits"
|
||||
$form->add('label', 'label_digits', 'digits', 'Digits:');
|
||||
$obj = $form->add('text', 'digits');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'digits' => array('', 'error', 'Accepts only digits (0 to 9)')
|
||||
));
|
||||
$form->add('note', 'note_digits', 'digits', 'Accepts only digits (0 to 9)');
|
||||
|
||||
// "float"
|
||||
$form->add('label', 'label_float', 'float', 'Float:');
|
||||
$obj = $form->add('text', 'float');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'float' => array('', 'error', 'Accepts only digits (0 to 9) and/or one dot (but not as the very first character) and/or one minus sign (but only if it is the very first character)')
|
||||
));
|
||||
$form->add('note', 'note_float', 'float', 'Accepts only digits (0 to 9) and/or one dot (but not as the very first character) and/or one minus sign (but only if it is the very first character)');
|
||||
|
||||
// "length"
|
||||
$form->add('label', 'label_length', 'length', 'Length:');
|
||||
$obj = $form->add('text', 'length');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'length' => array(6, 12, 'error', 'Must contain between 6 and 12 characters!')
|
||||
));
|
||||
$form->add('note', 'note_length', 'length', 'Must contain between 6 and 12 characters');
|
||||
|
||||
// "number"
|
||||
$form->add('label', 'label_number', 'number', 'Number:');
|
||||
$obj = $form->add('text', 'number');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'number' => array('', 'error', 'Accepts only digits (0 to 9) and/or one minus sign (but only if it is the very first character)')
|
||||
));
|
||||
$form->add('note', 'note_number', 'number', 'Accepts only digits (0 to 9) and/or one minus sign (but only if it is the very first character)');
|
||||
|
||||
// "regular expression"
|
||||
$form->add('label', 'label_regexp', 'regexp', 'Regular expression:');
|
||||
$obj = $form->add('text', 'regexp');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
'regexp' => array('^07[0-9]{8}$', 'error', 'Validates only if the value matches the following regular expression: ^07[0-9]{8}$')
|
||||
));
|
||||
$form->add('note', 'note_regexp', 'regexp', 'Validates if the value satisfies the following regular expression: ^07[0-9]{8}$');
|
||||
|
||||
// "change case"
|
||||
$form->add('label', 'label_case', 'case', 'Change case:');
|
||||
$obj = $form->add('text', 'case');
|
||||
$obj->set_rule(array(
|
||||
'required' => array('error', 'This field is required!'),
|
||||
));
|
||||
// force all characters to be upper-case
|
||||
$obj->change_case('upper');
|
||||
$form->add('note', 'note_case', 'case', 'All entered characters will be upper-case');
|
||||
|
||||
// "submit"
|
||||
$form->add('submit', 'btnsubmit', 'Submit');
|
||||
|
||||
// if the form is valid
|
||||
if ($form->validate()) {
|
||||
|
||||
// show results
|
||||
show_results();
|
||||
|
||||
// otherwise
|
||||
} else
|
||||
|
||||
// generate output using a custom template
|
||||
$form->render();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user