require_once($_SERVER['DOCUMENT_ROOT'] . '/php/site.php');
// Create the form
$survey = new JFormer('survey', array(
'submitButtonText' => 'Submit',
'title' => 'Likert Demo with Page Navigation
',
'pageNavigator' => true
));
// Create the form page
$jFormPage1 = new JFormPage($survey->id . 'Page', array(
'title' => 'Page 1'
));
// Create the form page
$jFormPage2 = new JFormPage($survey->id . 'Page2', array(
'title' => 'Page 2'
));
// Create the form section
$jFormSection1 = new JFormSection($survey->id . 'Section1', array(
));
// Create the form section
$jFormSection2 = new JFormSection($survey->id . 'Section2', array(
));
// Add components to the section
$jFormSection1->addJFormComponentArray(array(
new JFormComponentLikert('likert1', 'Please evaluate the following statements:',
array(
array('value' => '1', 'label' => 'Strongly Disagree', 'sublabel' => '1'),
array('value' => '2', 'label' => 'Disagree', 'sublabel' => '2'),
array('value' => '3', 'label' => 'Agree', 'sublabel' => '3'),
array('value' => '4', 'label' => 'Strongly Agree', 'sublabel' => '4'),
array('value' => '-', 'label' => 'No Opinion', 'sublabel' => '-'),
),
array(
array(
'name' => 'statement1',
'statement' => 'You really like JFormer.',
'validationOptions' => array('required'),
),
array(
'name' => 'statement2',
'statement' => 'Sometimes you dream about JFormer.',
),
array(
'name' => 'statement3',
'statement' => 'You want to donate to JFormer.',
'description' => 'You can do that conveniently here
',
'tip' => 'Oh My! I have a tip on this specific statement.
'),
),
array(
'validationOptions' => array('required'),
'description' => 'Likert description.
',
)
),
));
$jFormSection2->addJFormComponentArray(array(
new JFormComponentLikert('likert2', 'Just a few more questions:',
array(
array('value' => '1', 'label' => 'Strongly Disagree', 'sublabel' => '1'),
array('value' => '2', 'label' => 'Disagree', 'sublabel' => '2'),
array('value' => '3', 'label' => 'Agree', 'sublabel' => '3'),
array('value' => '4', 'label' => 'Strongly Agree', 'sublabel' => '4'),
array('value' => '-', 'label' => 'No Opinion', 'sublabel' => '-'),
),
array(
array(
'name' => 'question1',
'statement' => 'I don\' think I would ever use a likert.',
'validationOptions' => array('required'),
),
array(
'name' => 'question2',
'statement' => 'I could make something cooler than Jformer',
),
),
array(
'validationOptions' => array('required'),
'description' => 'Likert description.
',
)
),
));
// Add the section to the page
$jFormPage1->addJFormSection($jFormSection1);
$jFormPage2->addJFormSection($jFormSection2);
// Add the page to the form
$survey->addJFormPage($jFormPage1);
$survey->addJFormPage($jFormPage2);
// Set the function for a successful form submission
function onSubmit($formValues) {
return array(
'successPageHtml' => 'Thanks for Using jFormer
Thanks for trying out the Likert Demo
'
);
}
// Process any request to the form
$survey->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
