// Create the form
$login = new JFormer('loginForm', array(
'submitButtonText' => 'Login',
));
// Create the form page
$jFormPage1 = new JFormPage($login->id.'Page', array(
'title' => 'Login Demo
',
));
// Create the form section
$jFormSection1 = new JFormSection($login->id.'Section', array());
// Check to see if the remember me checkbox should be checked by default
// Add components to the section
$jFormSection1->addJFormComponentArray(array(
new JFormComponentSingleLineText('username', 'Username:', array(
'validationOptions' => array('required', 'username'),
'tip' => 'The demo login is admin.
',
)),
new JFormComponentSingleLineText('password', 'Password:', array(
'type' => 'password',
'validationOptions' => array('required', 'password'),
'tip' => 'Password is 12345
',
)),
new JFormComponentMultipleChoice('rememberMe', '',
array(
array('value' => 'remember', 'label' => 'Keep me logged in on this computer')
),
array(
'tip' => 'If a cookie is set you can have this checked by default.
',
)
),
));
// Add the section to the page
$jFormPage1->addJFormSection($jFormSection1);
// Add the page to the form
$login->addJFormPage($jFormPage1);
// Set the function for a successful form submission
function onSubmit($formValues) {
$formValues = $formValues->loginFormPage->loginFormSection;
if($formValues->username == 'admin' && $formValues->password == '12345') {
if(!empty($formValues->rememberMe)) {
$response = array('successPageHtml' => 'Login Successful
We\'ll keep you logged in on this computer.
');
}
else {
$response = array('successPageHtml' => 'Login Successful
We won\'t keep you logged in on this computer.
');
}
}
else {
$response = array('failureNoticeHtml' => 'Invalid username or password.', 'failureJs' => "$('#password').val('').focus();");
}
return $response;
}
// Process any request to the form
$login->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
