// Create the form
$contact = new JFormer('contactForm', array(
'submitButtonText' => 'Send',
'style' => 'width: 650px;',
));
// Create the form page
$page = new JFormPage($contact->id.'Page', array(
'title' => 'Contact Us
',
));
// Create the form section
$section = new JFormSection($contact->id.'Section', array());
// Add components to the section
$section->addJFormComponentArray(array(
new JFormComponentName('name', 'Name:', array(
'validationOptions' => array('required'),
)),
new JFormComponentSingleLineText('email', 'E-mail address:', array(
'width' => 'long',
'validationOptions' => array('required', 'email'),
)),
new JFormComponentSingleLineText('subject', 'Subject:', array(
'width' => 'longest',
'validationOptions' => array('required'),
)),
new JFormComponentTextArea('message', 'Message:', array(
'width' => 'longest',
'height' => 'medium',
'validationOptions' => array('required'),
)),
));
// Add the section to the page
$page->addJFormSection($section);
// Add the page to the form
$contact->addJFormPage($page);
// Set the function for a successful form submission
function onSubmit($formValues) {
$formValues = $formValues->contactFormPage->contactFormSection;
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 Contacting Us
Your message has been successfully sent.
';
return $message;
}
// Process any request to the form
$contact->processRequest();
©2012 Kirk Ouimet Design and Seth Z Jensen Design. All rights reserved. Privacy Policy and Terms of Service. Login.
