xajax:
function CreateNews()
{
$this->load->model('MyForm');
$data = $this->MyForm->myvalidation();
$objResponse = new xajaxResponse();
$objResponse->Assign("content","innerHTML", $data);
return $objResponse;
}
}
Validation - Model MyForm:
function myvalidation(){
# Validations
$this->load->library('validation');
$this->load->helper('form');
$rules['fname'] = "required";
$rules['email'] = "required|valid_email";
$this->validation->set_rules($rules);
# Input and textarea field attributes
$data["fname"] = array();
$data['email'] = array();
$data['comments'] = array();
if ($this->validation->run() == FALSE)
{
$this->validation->set_fields($data);
# Input and textarea field attributes
$data["fname"] = array('name' => 'fname', 'id' => 'fname', 'value' => $this->validation->fname);
$data['email'] = array('name' => 'email', 'id' => 'email', 'value' => $this->validation->email);
$data['comments'] = array('name' => 'comments', 'id' => 'comments', 'rows' => 3, 'cols' => 40);
$output = $this->load->view('form_view', $data, true);
}
else
{
$output = $this->load->view('succes_view', $data, true);
}
return $output;
}
Form:
<form name="test" id="test">
<p><label for="fname">Full Name: </label><br /><?php echo form_input($fname); ?></p>
<p><label for="email">E-mail: </label><br /><?php echo form_input($email); ?></p>
<p>Please select one or more seminars, that you would like to attend</p>
<p><?php echo form_checkbox($purpose); ?> <label for="purpose">Purpose of Prayer</label></p>
<p><?php echo form_checkbox($prepare); ?> <label for="prepare">Prepare for Prayer</label></p>
<p><?php echo form_checkbox($principles); ?> <label for="principles">Principles of Prayer</label></p>
<p><?php echo form_checkbox($power); ?> <label for="power">Power in Prayer</label></p>
<p><label for="comments">Comments: </label><br /><?php echo form_textarea($comments); ?></p>
a href="#" xajax_CreateNews(xajax.getFormValues("test", false));'>Save