⚠ 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

To order the dropdown list maked with $crud->set_relation



cesaret_2000

cesaret_2000
  • profile picture
  • Member

Posted 01 March 2012 - 10:54 AM

Hi folks.

Is it possible to order the dropdown list maked with $crud->set_relation? I explain myself...

Imagine I have a table 'music_bands' with a column 'type_id' wich refers to a table 'type_band'. So, I'd implement it like...

[color=#ff0000]$crud->set_relation('type_id', 'type_band', 'band_description')[/color]

That will make a dropdown list in the add/edit form ordered by 'band_description'. Whay I'd like [b]it's to choose this order[/b], for example, order it by the 'type_id'.

Ok, there's this an option: [color=#ff0000]$crud->set_relation('type_id', 'type_band', '{type_id} - {band_description}')[/color], but I don't like it, because I just want to see in the list the drescription.

Any suggestion?

Thanks a million.

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 03 March 2012 - 16:51 PM

From the new version 1.2 I will have a where clause at the 4th argument to the simple set_relation method and an order by clause at the 5th argument to the simple set_relation method.

For example:


$crud->set_relation('type_id', 'type_band', '{type_id} - {band_description}',array('status' => 1),'type_id');


or if you don't want the 4th parameter with a where clause you can simply do:


$crud->set_relation('type_id', 'type_band', '{type_id} - {band_description}',null,'type_id');


This functionality is already done so you can download the latest trunk version from github ( https://github.com/scoumbourdis/grocery-crud/zipball/master ).

cesaret_2000

cesaret_2000
  • profile picture
  • Member

Posted 05 March 2012 - 08:43 AM

Thanks, it's working.

ashish_nirkhe

ashish_nirkhe
  • profile picture
  • Member

Posted 12 September 2012 - 16:48 PM

Hi,
I have one doubt. How do we specify multiple conditions in where clause.
e.g. I want drop down list with status as 1 or status as 3

how to get this one?

can you please help.

Thank you.

Regards,
Ashish Nirkhe