require_once($_SERVER['DOCUMENT_ROOT'] . '/php/site.php');
// Create the form
$registration = new JFormer('registration', array(
'submitButtonText' => 'Register',
));
// Create the form page
$jFormPage1 = new JFormPage($registration->id . 'Page', array(
'title' => 'Registration Demo
',
'description' => 'None of your data from this form is acutally stored, so feel free to put whatever.
',
));
// Create the form section
$jFormSection1 = new JFormSection($registration->id . 'Section1', array(
));
// Create the form section
$jFormSection2 = new JFormSection($registration->id . 'Section2', array(
));
// Add components to the section
$jFormSection1->addJFormComponentArray(array(
new JFormComponentSingleLineText('username', 'Username:', array(
'validationOptions' => array('required', 'username'),
)),
new JFormComponentSingleLineText('email', 'E-mail Address:', array(
'validationOptions' => array('required', 'email'),
)),
new JFormComponentSingleLineText('password', 'Password:', array(
'type' => 'password',
'validationOptions' => array('required', 'password'),
)),
new JFormComponentSingleLineText('passwordConfirm', 'Confirm Password:', array(
'type' => 'password',
'validationOptions' => array('required', 'password', 'matches' => 'password'),
)),
new JFormComponentMultipleChoice('updates', '', array(
array('value' => 'signup', 'label' => 'I would like to recieve updates.'),
),
array()),
new JFormComponentMultipleChoice('update_type', 'How would you like to recieve updates?', array(
array('value' => 'Email', 'label' => 'Send updates to my Email'),
array('value' => 'Text Message', 'label' => 'Send updates to my Phone via Text Message'),
),
array(
'multipleChoiceType' => 'radio',
'validationOptions' => array('required'),
'dependencyOptions' => array(
'dependentOn' => 'updates',
'display' => 'hide',
'jsFunction' => '$("#updates-choice1").is(":checked");'
),
)),
new JFormComponentSingleLineText('phone', 'Phone Number:', array(
'mask' => '(999) 999-9999',
'validationOptions' => array('required'),
'dependencyOptions' => array(
'dependentOn' => array('update_type', 'updates'),
'display' => 'hide',
'jsFunction' => '$("#update_type-choice2").is(":checked") && $("#updates-choice1").is(":checked");'
),
)),
new JFormComponentMultipleChoice('terms', '', array(
array('value' => 'agree', 'label' => 'Do you agree to the site Terms and Conditions?'),
),
array(
'validationOptions' => array('required'),
)),
));
// Add the section to the page
$jFormPage1->addJFormSection($jFormSection1);
// Add the page to the form
$registration->addJFormPage($jFormPage1);
// Set the function for a successful form submission
function onSubmit($formValues) {
//return array('failureHtml' => json_encode($formValues));
$secondary = '';
if ($formValues->registrationPage->registrationSection1->updates[0] == 'signup') {
$updates = 'yes';
// type, and detail
$type = $formValues->registrationPage->registrationSection1->update_type;
$secondary = 'Update Type: ' . $type . '
';
if ($type == 'phone') {
$secondary .= 'Phone Number: ' . $formValues->registrationPage->registrationSection1->phone . '
';
}
} else {
$updates = 'no';
}
return array(
'successPageHtml' => 'Thanks for Using jFormer
Username: ' . $formValues->registrationPage->registrationSection1->username . '
E-mail: ' . $formValues->registrationPage->registrationSection1->email . '
Updates
Receive Updates: ' . $updates . '
'.$secondary,
);
}
// Process any request to the form
$registration->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
