Exemplo n.º 1
0
function contactform_ajax(cs_form $form, &$form_state)
{
    // $form = new cs_form(array(
    //   'form_id' => __FUNCTION__,
    //   'ajax_submit_url' => 'ajax_url.php',
    //   'output_type' => 'json',
    // ));
    $form->set_form_id(__FUNCTION__);
    $form->set_ajax_submit_url('ajax_url.php');
    $form->set_output_type('json');
    $form->add_field('name', array('type' => 'textfield', 'validate' => array('required'), 'preprocess' => array('trim'), 'title' => 'Your name'));
    $form->add_field('email', array('type' => 'textfield', 'validate' => array('required', 'email'), 'title' => 'Your email address'));
    $form->add_field('message', array('type' => 'textarea', 'postprocess' => array('xss'), 'title' => 'Your message'));
    $form->add_field('submit', array('type' => 'submit'));
    $form->add_field('message2', array('type' => 'textarea', 'postprocess' => array('xss'), 'title' => 'Your message 2'), 1);
    $form->add_field('submit2', array('type' => 'submit'), 1);
    return $form;
}