Welcome Guest, Not a member yet? Register   Sign In
Can't use call back function in form validation
#1

[eluser]weblizzer[/eluser]
Hi Everyone,

I just have a question, why I can't call my callback function within the model? I put my validation of model and I have 2 call back function which I will be call for custom validation. Only the problem is that when It doesn't perform the callback function though when I try to put it into the controller it does work.

Any advise?

Thanks
#2

[eluser]smilie[/eluser]
As far as I got with controller > model (and forms) - model has no idea about the form what so ever.
My workaround is to pass (once more) all form values from controller to model. Not the nicest / easiest way, but it works.

Regards,
Smilie
#3

[eluser]flaky[/eluser]
I take this way of coding

Views - GUI, User Interface
Controller - Application logic and data validation
Models - Database layer access

Form validation callback, by this logic fall into the controller not model
#4

[eluser]Eric Barnes[/eluser]
Or just create a wrapper to the model. This would be in controller:
Code:
public function username_check($username)
{
    if ( ! $this->user_model->check_unique($username))
    {
        $this->form_validation->set_message('username_check', lang('lang_username_in_use'));
        return FALSE;
    }
    else
    {
        return TRUE;
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB