protected $rules = array(
'name' => array(
'field' => 'name',
'label' => 'Name',
'rules' => 'trim|required|min_length[2]',
),
'email' => array(
'field' => 'email',
'label' => 'Email address',
'rules' => 'trim|required|valid_email',
),
'phone' => array(
'field' => 'phone',
'label' => 'Phone number',
'rules' => 'trim|required',
),
'comments' => array(
'field' => 'comments',
'label' => 'Comments',
'rules' => 'trim|required|min_length[10]',
),
);
// in my method, where I run the validation
if ($topic == 'Employment query' && count($_FILES)) {
$config['max_size'] = '5000';
$config['upload_path'] = 'content/cvs';
$config['allowed_types'] = 'doc|docx|pdf|odt';
$this->load->library('upload', $config);
if ($this->upload->do_upload('upload_cv')) {
$cv_file = $this->upload->data();
}
else {
$this->data['upload_error'] = $this->upload->display_errors('<span class="help-block">', '</span>');
}
}
$this->form_validation->set_rules($this->rules);
if ($this->form_validation->run()) {
// get form data and send email
redirect('contact/thank_you');
}