I am using the form validation library however I have come across something I cannot work out how to do.
I have several fields,
I have:
- page_title => required
- menu_title => not required
- parent_id => null or required
Now if menu_title is not set then it should take on the value of page_title.
Then, I need to do a check to make sure that, at the given level the menu_title is unique.
So,
if($menu_title == '')
$menu_title = $page_title;
return $this->db->
select('menu_title')->
from('cart_categories')->
where(array('menu_title' => $menu_title,
'parent_id' => $category_parent))->
get()->num_rows() == 0;
But I don't know how to actually use that in the form validation library?
$this->input->post('whatever')but that doesn't seem right to me.$this->form_validation->set_rules('menu_title', 'Menu Title', my_callback_function);, and evaluate the query result in the function. See the docs for an example of how to write it, ctrl-f and look forCallbacks.