Hello,
I'm having a problem using field_type.
In the documentation it is said that we have to write the values like this:
$crud->field_type('status','enum',array('active','private','spam','deleted'));
I would like to get the values from the Data base then I wrote a function in model to obtain the values:
public function select_values($val=1) {
$sql = "SELECT id, name FROM table_nav WHERE val='$val'";
$query = $this->db->query($sql);
$result = '';
foreach($query->result() AS $row) {
$result .= "'".$row->nav_name."',";
}
$result= substr($result, 0, -1);
return $result;
}
And in the controler I have this:
$arrayvalues = $this->Model_content->select_values();
$this->grocery_crud->field_type('nav_parent','enum',array($arrayvalues));
If I do an echo of $arrayvalues, I have this:
'active','private','spam','deleted'
If I change my code to...
$this->grocery_crud->field_type('nav_parent','enum',array('active','private','spam','deleted'));
... all work fine (image2) but if I change it to...
$this->grocery_crud->field_type('nav_parent','enum',array($arrayvalues));
... it doesn't work (image1).
Do you kwow why does it happen?
And how to solve it?
Thanks a lot.
Best
