⚠ 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 forum is read-only and soon will be archived. ⚠


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

callback_column set_relation

  • Please log in to reply
2 replies to this topic

#1 djeby

djeby

    Newbie

  • Members
  • Pip
  • 3 posts

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



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

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 :)



#3 djeby

djeby

    Newbie

  • Members
  • Pip
  • 3 posts

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..!!







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users