⚠ 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

display different values on dropdownlist field & table column when using set_relation



djeby

djeby
  • profile picture
  • Member

Posted 25 November 2014 - 10:34 AM

I have 2 tables, order & software_list and table details are :

 

1. order :

id_order

software_list_fk

quantity

 

2. software_list :

id_software

software_name

part_number

 

 

I want to display different values on dropdownlist field & table column. This is my code for dropdownlist values on field :

public function orders_management()
{
    try{
        $crud = new grocery_CRUD();

        $crud->set_table('order');
        $crud->set_subject('Order');
        $crud->display_as('software_list_fk','Software');
        $crud->set_relation('software_list_fk','software_list', '{software_name} | {part_number}');         

    }catch(Exception $e){
        show_error($e->getMessage().' --- '.$e->getTraceAsString());
    }
}

This works for my dropdownlist values as shown below :

 

dropdownlist.png

 

but I only want to display 'software_name' in table column not 'software name | part_number' as shown below :

 

orders.png

 

 

I tried to use callback_column but didn't work.

So, how to resolve that problem?

 

Thanks in advance


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 25 November 2014 - 12:23 PM

Hi there

 

Well simple solution - set relation u can manage it 2 ways - 1 if $crud->getState() == 'add'  OR  'edit' - then merge the 2 values... else just use the software name and not the price.

 

Happy Gcing :)


djeby

djeby
  • profile picture
  • Member

Posted 26 November 2014 - 02:45 AM

Hi there

 

Well simple solution - set relation u can manage it 2 ways - 1 if $crud->getState() == 'add'  OR  'edit' - then merge the 2 values... else just use the software name and not the price.

 

Happy Gcing :)

 

Wow, it works..!!

 

OMG, I have no idea if there is getState function.

Thank you very much..!!