Welcome Guest, Not a member yet? Register   Sign In
Preventing custom form validation function from being accessed via a URL
#3

(This post was last modified: 05-04-2016, 04:00 AM by CINewb.)

(05-04-2016, 03:29 AM)keulu Wrote: <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function city_check($postfield){
global $CI;
if ($postfield == '0'){
$CI->form_validation->set_message('city_check', 'Need city');
return FALSE;
}else{
return TRUE;
}
}


// in your controller
$this->load->helper('form_validation');
$this->form_validation->set_rules('email', 'Email', 'callback_city_check' );

Thanks.  The only thing is, my custom form validation method is currently in a controller, and it calls a method from the related model.  If I create a helper this would need to be generic, and not related to the controller/model in question.

Here's what my validation method looks like at the moment:


PHP Code:
public function check_loggedin() {
        if ( $this->user_model->is_loggedin() ) {
            return true;
        }
        return false;

Reply


Messages In This Thread
RE: Preventing custom form validation function from being accessed via a URL - by CINewb - 05-04-2016, 04:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB