Welcome Guest, Not a member yet? Register   Sign In
validation dunamically created fields
#3

[eluser]dimis[/eluser]
I have this code
Code:
function add()
    {
      
        $name=array();
        $lancode=$this->lans->returnonlycode($lancode);

        // echo ($lancode[1]['lan_code']);
        $this-> myvalidproduct($lancode);
        if ($this->validation->run() == FALSE)
        { echo  $this->validation->error_string;

        }.......
Code:
function myvalidproduct($lancode)
    {      
    
        $this->load->library('validation');

        $fields['code']= "code";
        //  $fields['active']= "active";
        //  $fields['material']= "material";
        foreach ($lancode as $lan)
        {
            $el="name_".$lan['lan_code'];
            $fields["$el"]= "$el";
            $rules["$el"]= "required";

        }
        $rules['code']    = "required";
        //   $rules['active']    = "active";
        //  $rules['material']    = "material";
        $this->validation->set_fields($fields);
        $this->validation->set_rules($rules);
    }
Code:
function returnonlycode()
    {
        $data = array();
        $this->db->select('lan_code');
        $query= $this->db->get('lan');
        if ( $query-> num_rows() > 0){
            foreach ( $query-> result_array() as $row){
                $data[] = $row;
            }
        }
        $query-> free_result();

        return $data;
    }
I make this validation with ajax, when I remove the code for the array the validation works also with the code for the array the validation does not work!


Messages In This Thread
validation dunamically created fields - by El Forum - 09-17-2008, 12:48 AM
validation dunamically created fields - by El Forum - 09-17-2008, 12:55 AM
validation dunamically created fields - by El Forum - 09-17-2008, 01:08 AM
validation dunamically created fields - by El Forum - 09-17-2008, 01:52 AM
validation dunamically created fields - by El Forum - 09-17-2008, 01:53 AM
validation dunamically created fields - by El Forum - 09-17-2008, 02:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB