php - codeigniter callback from private methods not working -
i doing form validation in codeigniter using form validation library , custom callbacks.
public function insert_user() { if($this->input->post('submit')) { // load form validation library $this->load->library('form_validation'); // configurations $config = array( array( 'field' => 'username', 'label' => 'username', 'rules' => 'required|callback_username_check' ) ); $this->form_validation->set_rules($config); // .... continue .... } }
when method public, working expected.
public function username_check($username) { // stuffs here }
when make method private, not working.
private function username_check($username) { // stuffs here }
why callbacks private methods not working?
why need this?
public methods in codeigniter controllers accessible urls example above
i don't want callback methods accessible publicly.
the callback function must public. codeigniter form validation class access function @ current controller may not private..
to go around problem may think extending ci_form_validation class my_form_validation..
class my_form_validation extends ci_form_validation { public function __construct() { parent::__construct(); } function username_check($str) { /* code */ } }
then in validation must set only..
'rules' => 'required|username_check'
Comments
Post a Comment