⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

set_relation_n_n get values from relation table



ananina

ananina
  • profile picture
  • Member

Posted 29 January 2015 - 05:30 AM

Hello,

 

I have a doubt about set_relation_n_n. I need to show a value from relation table.

In this example http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n  , its like a need to show priority value, conditioned to a where clause from selection_table.

 

Something like that:

 

$where = "actor_id = 1"; 

$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'priority', $where);

 

I've tried with set_model but on read or edit only shows fields the FROM table

 

Any ideas?

 

 


jinbatsu

jinbatsu
  • profile picture
  • Member

Posted 29 January 2015 - 11:19 AM

In the sample it show the fullname, NOT the priority.
 
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority');
 
If you want to add where, you should do like this:
 
$where = "actor_id = 1"; 
$crud->set_relation_n_n('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname','priority', $where);

So, where condition is in the 8 position, not in the 7.

6 position is for display name

7 position is for priority (field name for sorting order ASC).

8 position is for where condition.