Faisal Naseer
Faisal Naseer

Reputation: 4248

Dynamic Dropdown from database in add template Grocery Crud

I am having two relations first one category/second one product and the roduct relation contains the foreign key from the category relation. in my add template of product I wan to have a dynamic dropdown to select form categories. Right now I'm using this way.

 $crud->field_type('cat_id','dropdown', array('1' => 'Boxes', '2' => 'Supliments'));

but its is creating a static dropdown. As if any new category is added it doesn't reflect change over here and if i don't specify this I get a simple input field where I have to specify category myself. Right now I am using bootstrap theme. Is there any way I can create a dynamic dropdown?

Upvotes: 0

Views: 1420

Answers (1)

Samson Nzuki
Samson Nzuki

Reputation: 51

There is a set_relation() function in the grocery crud documentation that may solve your challenge.You can view the information via this link http://www.grocerycrud.com/examples/set_a_relation

Upvotes: 1

Related Questions