[eluser]mathinoz[/eluser]
Hello, I am new to codeigniter (and to programming) and i am having the following problem.
I have created my controller that lists the entries of the table, deletes an entry and of course adds an entry or edit an entry. I wanted to avoid having dublicate ('title') entries so i have created my own callback validation function to avoid this and this works fine when i add a new entry.. BUT there is a problem when i edit an entry.
When i add a new entry i can check succesfully if the new title already exist in my database, but I cannot use my callback function when i edit an entry cause it will always produce an error.
My callback function is the following
$rules['domain']= "callback_duplicate_entry"; - this is the way i call it in my controller
and the actual function is
function duplicate_entry()
{
$this->load->model('Mdomains', '', TRUE);
$checktitles['data'] = $this->Mdomains->getalldomains();
foreach ($checktitles['data'] as $v){
if ($v['domain'] == $this->input->post('domain'))
{
$this->validation->set_message('duplicate_entry', 'The domain name - ['.$this->input->post('domain').'] already exist.');
return FALSE;
}
}
SO as you can guess when i edit an entry, the title exists in the database and the callback function will ALWAYS produse an error.
Is the method i am using in the validation callback function correct? should i do it in a different way?
Any ideas?
Thanks