Welcome Guest, Not a member yet? Register   Sign In
MY_Form_validation working for some functions
#1

[eluser]ash0803[/eluser]
Hi guys

I am having trouble using extending the CI_Form_validation class. Some of the functions work fine (validating on text input boxes) while others don't work at all. The functions don't even get invoked.

The functions that don't get invoked are called from validating an array of checkboxes and from validating a file upload input. If I use callback functions from within the actual controllers there's no problem. It's only when I put them in the MY_Form_validation class.

Here's a sample. Any ideas?

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation
{

    function __construct()
    {
        parent::__construct();
    }

    function check_valid_postcode($pc) // works absolutely fine
    {
        $ci=& get_instance();
        $ci->load->model('postcode_model');
        // first make the postcode correct format
        return $ci->postcode_model->validate_postcode($pc);
    }

    function check_nickname_unique($nickname,$cid) // also fine
    {
        $ci=& get_instance();
        if(!$ci->customer_account_model->is_nickname_unique($nickname,$cid))
        {
            $ci->form_validation->set_message('check_nickname_unique', 'Nickname is taken. Please choose another');
            return FALSE;
        }
        return TRUE;
    }

    function handle_upload($image,$v=array())
    {
        show_error('hello'); // this doesn't get invoked
        $ci=& get_instance();
        if(!empty($v)) $v='_'.$v;
        $ci->load->library('upload');

        if($ci->upload->do_upload('image_upload'.$v))
        {
            $_POST['image_upload'.$v] = $this->upload->data();
            return TRUE;
        }
        else
        {
            $ci->form_validation->set_message('handle_upload', $ci->upload->display_errors());
            return FALSE;
        }
    }

}

Thanks


Messages In This Thread
MY_Form_validation working for some functions - by El Forum - 02-18-2013, 03:01 AM
MY_Form_validation working for some functions - by El Forum - 02-18-2013, 10:34 AM
MY_Form_validation working for some functions - by El Forum - 02-18-2013, 11:18 AM
MY_Form_validation working for some functions - by El Forum - 05-26-2014, 04:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB