• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't use call back function in form validation

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?


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.


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

[eluser]Eric Barnes[/eluser]
Or just create a wrapper to the model. This would be in controller:
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;
        return TRUE;

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.