I've used Codeigniter for a while and whilst I've not always found the form validation as straightforward as I'm sure it should be I've never had any massive problems... until now!
I have a simple form comprised of text inputs and a textarea. The form starts off prepopulated and, if the validation fails, repopulates it with the last changed state.
My problem is this - The textarea needs to accept pound signs (£). It populates text from the database absolutely fine but on submit, whether the form validates or not, it strips them out, regardless of what I do!!
I've scoured the net and can only find solutions about applying things like htmlentities to the validation rules, but if I firephp the post data out, even before the rules, it's already been stripped out.
global_xss_filtering is set to false in my config.
It's driving me mad and wasting way more time than it should... has anyone got a solution to this, I know I'm probably missing something really simple - it's maddening!
Thanks,
Helen
Here's my validation code, although the firephp log at the top shows it to already be stripped out so I can't see how doing anything here will help... I've tried adding the various php function as it suggests HERE (codeigniter manual) but it makes no difference at all.
public function edit_entry2($entry_id, $page_id) {
$this->firephp->log($_POST);
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required|max_length[255]');
$this->form_validation->set_rules('address1', 'Address line 1', 'max_length[255]');
$this->form_validation->set_rules('address2', 'Address line 2', 'max_length[255]');
$this->form_validation->set_rules('address3', 'Address line 3', 'max_length[255]');
$this->form_validation->set_rules('address4', 'Address line 4', 'max_length[255]');
$this->form_validation->set_rules('county', 'County', 'required|max_length[255]');
$this->form_validation->set_rules('post_code', 'Post Code', 'max_length[10]');
$this->form_validation->set_rules('telephone1', 'Telephone 1', 'required|max_length[12]|is_natural');
$this->form_validation->set_rules('telephone2', 'Telephone 2', 'max_length[12]|is_natural');
$this->form_validation->set_rules('fax', 'Fax', 'max_length[12]|is_natural');
$this->form_validation->set_rules('email', 'Email address', 'valid_email');
$this->form_validation->set_rules('website', 'Website', 'max_length[255]');
$this->form_validation->set_rules('rating_awards', 'Rating/Awards', 'max_length[255]');
$this->form_validation->set_rules('description', 'Description', 'max_length[1000]');
$this->form_validation->set_rules('categories[]', 'Categories', 'callback_categories_check');
if ($this->form_validation->run() == FALSE)
{
$this->edit_entry($entry_id, $page_id);
}
else
{
$updated_entry = array('name'=>$_POST['name'], 'address1'=>$_POST['address1'], 'address2'=>$_POST['address2'], 'address3'=>$_POST['address3'], 'address4'=>$_POST['address4'], 'county'=>$_POST['county'], 'post_code'=>$_POST['post_code'], 'telephone1'=>$_POST['telephone1'], 'telephone2'=>$_POST['telephone2'], 'fax'=>$_POST['fax'], 'email'=>$_POST['email'], 'website'=>$_POST['website'], 'rating_awards'=>$_POST['rating_awards'], 'description'=>$_POST['description']);
$this->tourism_catalogue_model->update_entry($entry_id, $updated_entry, $_POST['categories']);
$this->index($page_id);
}
}