{zebra_library}->create_form('contact_form'); # form for the contact page function zf_contact() { // instantiate a Zebra_Form object $form = new Zebra_Form('contact'); # necessary for CodeIgnition's CSRF $CI = get_instance(); $obj = $form->add('hidden', $CI->security->get_csrf_token_name(), $CI->security->get_csrf_hash()); $obj->lock(); // "subject" $form->add('label', 'label_subject', 'subject', 'Subject:'); $obj = $form->add('select', 'subject'); $obj->add_options(array( 'Advertising Comment', 'Business Proposals', 'Careers/Employment', 'Contributions/Donations/Sponsorship', 'Investor Relations', 'Website Idea', 'Website Inquiry/Complaint', 'Other / General Questions' )); $obj->set_rule(array( 'required' => array('error', 'Subject is required!') )); // the label for the "first name" field $form->add('label', 'label_contact_name', 'contact_name', 'Name:'); // add the "first name" field // the "&" symbol is there so that $obj will be a reference to the object in PHP 4 // for PHP 5+ there is no need for it $obj = $form->add('text', 'contact_name'); // set rules $obj->set_rule(array( // error messages will be sent to a variable called "error", usable in custom templates 'required' => array('error', 'A name is required!'), )); // "contact_email" $form->add('label', 'label_contact_email', 'contact_email', 'Email address:'); $obj = $form->add('text', 'contact_email'); $obj->set_rule(array( 'required' => array('error', 'Email is required!'), 'email' => array('error', 'Email address seems to be invalid!') )); // attach a note to the email element $form->add('note', 'note_contact_email', 'contact_email', 'Please enter a valid email address so that we may reach you.', array('style'=>'width:200px')); // "message" $form->add('label', 'label_message', 'message', 'Message:'); $obj = $form->add('textarea', 'message'); $obj->set_rule(array( 'required' => array('error', 'Message is required!') )); // "captcha" $form->add('captcha', 'captcha_image', 'captcha_code'); //$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?'); $obj = $form->add('text', 'captcha_code'); $form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters in black that stand out from the other characters. Not case sensitive.', array('style'=>'width: 200px')); $obj->set_rule(array( 'captcha' => array('error', 'Characters from image entered incorrectly!') )); // "ip" $obj = $form->add('hidden', 'ip', $_SERVER["REMOTE_ADDR"]); $obj->lock(); // "submit" $form->add('submit', 'btnsubmit', 'Submit'); return $form; }