-
Notifications
You must be signed in to change notification settings - Fork 7
Form Handling & Validation
jimmysparkle edited this page Aug 18, 2010
·
1 revision
Atsumi has built in systems to make Form handling easy & robust. New elements & validators can easily be created for specific requirements.
A Form is made up of a Form widget and one or more input elements (each element can optionally hold various validators). The Form widget basically holds the elements and can be tested on to see if the form has been successfully completed. The input elements make up textfields, checkboxes etc. Each input element can optionally hold validators to test the users input. Validators include minimum characters (text), maximum characters (text), filesize (file), filetype (file), required (all) etc.
$form = new widget_Form ('loginForm');
$form->setSubmit("Login");
$form->add( 'widget_TextElement',
array ( 'label' => 'Email Address',
'name' => 'email',
'validators' => array(
new validate_Required(),
new validate_EmailAddress(),
)
)
);
$form->add( 'widget_PasswordElement',
array ( 'label' => 'Password',
'name' => 'password',
'validators' => array (
new validate_Required(true)
)
)
);
if ($form->completed()) {
/* test details & process login */
} elseif ($form->getSubmitted() && !$form->getValidates()) {
/* could inform the user that their login form doesn't validate */
}