[eluser]Jevedor[/eluser]
This is driving me nuts
I am using a custom call back and i am pretty sure I am doing it correctly as I have used this exact same function on other website and it has worked fine.
this is the relevant code
Code:
function title_check () {
$this->db->where('news_title', $_POST['news_title']);
$check = $this->db->get('news');
$news = $check->row();
$allowed = $this->form_functions->allowed_characters('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890&/- '."'".'"');
$valid_chars = $this->form_functions->compare_allowed_characters($_POST['news_title'], $allowed);
if (!$valid_chars) {
$this->form_validation->set_message('title_check', 'Titles may only use spaces, letters, numbers, ampersands, forward slashes or hyphens');
return false;
} else if (!empty($news)) {
$seg3 = $this->uri->segment(3);
if (empty($seg3) || (!empty($seg3) && $news->news_id != $seg3)) {
$this->form_validation->set_message('title_check', 'This Title has already been created');
return false;
} else {
return true;
}
} else {
return true;
}
}
Code:
function create_news() {
//Check incoming variables
$this->form_validation->set_rules('news_title', 'News Title', "required|callback_title_check");
$this->form_validation->set_rules('category_id', 'Category', "required|integer");
$this->form_validation->set_rules('href', "Redirect URL");
$this->form_validation->set_rules('target', 'Target', "required");
$this->form_validation->set_rules('news_date', 'Date');
$this->form_validation->set_rules('news_content', 'News Content');
$this->form_validation->set_rules('meta_description', 'Meta Description');
$this->form_validation->set_rules('meta_keywords', 'Meta Keywords');
if (($this->form_validation->run() == false || !empty($_POST['edit']))) {
$this->template->create_template('Create News Item :: News Admin', 'news_admin/news_form', $data);
} else {
...
}
}
why are my error messages not working?? i have gone so far as to make my custom message look like this just to test it and it still doesnt work.
Code:
function title_check () {
$this->form_validation->set_message('title_check', 'Titles may only use spaces, letters, numbers, ampersands, forward slashes or hyphens');
return false;
}
help?