No one know how to filter the list query in an n-to-n relation?
I try to use set_model() but maybe I misunderstood something...
I changed my code like:
$crud->set_model('Houses_custom_model');
$crud->set_theme('datatables');
$crud->set_subject('Casette');
$crud->set_table('tbl_houses');
$crud->set_relation_n_n('Casette',
'tbl_users_houses',
'tbl_users',
'house_id',
'usr_id',
'usr_name',
NULL,
array('usr_id' => $usr_id));
And in my custom model put:
class Houses_custom_model extends Grocery_crud_model
{
function get_relation_n_n_unselected_array($field_info, $selected_values)
{
$selection_primary_key = $this->get_primary_key($field_info->selection_table);
// Here I do nothing...
//$results = $this->db->get($field_info->selection_table)->result();
$results_array = array();
foreach($results as $row)
{
if(!isset($selected_values[$row->{$field_info->primary_key_alias_to_selection_table}]))
$results_array[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->{$field_info->title_field_selection_table};
}
return $results_array;
}
}
and I get the list too also if I don't have made a query...
Now I have some questions:
- which method I have to override?
- which differences are between get_relation_n_n_unselected_array() and get_relation_n_n_selection_array()?
Thanks in advance to anyone who wanna give me an hint :)