// Create the form
$shoppingCart = new JFormer('paymentForm', array(
'action' => '/'.str_replace($_SERVER['DOCUMENT_ROOT'], '', __FILE__),
'submitButtonText' => 'Checkout',
'style' => 'width: 650px;',
));
// Create the form page
$page = new JFormPage($shoppingCart->id.'Page', array(
'title' => 'Billing Information
',
));
// Create the form section
$section = new JFormSection($shoppingCart->id.'Section', array());
// Add components to the section
$section->addJFormComponentArray(array(
new JFormComponentName('name', 'Name:', array(
'validationOptions' => array('required'),
'middleInitialHidden' => true
)),
new JFormComponentAddress('billing', 'Billing Address:', array(
'validationOptions' => array('required'),
)),
new JFormComponentMultipleChoice('billing_shipping', '',
array(
array('value' => '1', 'label' => 'My Shipping Address is different than my billing address'),
),
array()
),
new JFormComponentAddress('shipping', 'Shipping Address:', array(
'dependencyOptions' => array(
'dependentOn' => 'billing_shipping',
'display' => 'hide',
'jsFunction' => '$("#billing_shipping-choice1").is(":checked");'
),
'validationOptions' => array('required'),
)),
new JFormComponentCreditCard('cc_info', 'Billing Information:', array(
'validationOptions' => array('required'),
)
),
new JFormComponentMultipleChoice('terms', '',
array(
array('value' => 'agree', 'label' => 'I agree to the Terms and Conditions.'),
),
array(
'validationOptions' => array('required'),
)
)
));
// Add the section to the page
$page->addJFormSection($section);
// Add the page to the form
$shoppingCart->addJFormPage($page);
// Set the form session variable
$_SESSION[$shoppingCart->id] = $shoppingCart;
// Set the function for a successful form submission
function onSubmit($formValues) {
$formValues = $formValues->contactFormPage->contactFormSection;
// make comment that would show what a comment would look like.
if(!empty($formValues->name->middleInitial)) {
$name = $formValues->name->firstName.' '.$formValues->name->middleInitial.' '.$formValues->name->lastName;
}
else {
$name = $formValues->name->firstName.' '.$formValues->name->lastName;
}
$message['failureHtml'] = 'Thanks for Commenting
Your comment has been successfully submitted.
';
return $message;
}
// Process any request to the form
$shoppingCart->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
