[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!