⚠ 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 where expression in multiple set_relation()



Attila Balazs
  • profile picture
  • Member

Posted 19 April 2014 - 13:01 PM

Hello,

 

I have problem with set relation. When edit form shows, i would like to filter results in dropdowns by category id. (Show only news in same category of slider ) 
 
My db structure:
 
 
My scripts: 
 
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('Slider');
$crud->set_subject('Sides');
$crud->required_fields("slide_1_news_id","slide_2_news_id","slide_3_news_id","slide_4_news_id","slide_5_news_id");
            $crud->set_relation('slide_1_news_id','News','news_title');
            $crud->set_relation('slide_2_news_id','News','news_title');
            $crud->set_relation('slide_3_news_id','News','news_title');
            $crud->set_relation('slide_4_news_id','News','news_title');
            $crud->set_relation('slide_5_news_id','News','news_title');
$crud->set_relation('category_id','Category','category_name');
$crud->display_as('category_id','Category')
->display_as('slide_1_news_id','First news')
->display_as('slide_2_news_id','Second news')
->display_as('slide_3_news_id','Third news')
->display_as('slide_4_news_id','Fourth news')
->display_as('slide_5_news_id','Fifth news');
 
   $crud->field_type("category_id","readonly");
$output = $crud->render();

 

Regards,

Attila