Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grocery CRUD relation n_n - how to complete an other field in relational table

I have an application where I use Codeigniter + Grocery CRUD.

I was making a "n_n" relation , but in table that store the relation there is a third field.

Bellow my DB structure:

enter image description here

Grocery CRUD allows me to select the socialmedia as displayed bellow:

enter image description here

The complete functionality is showed here: http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n

How can I complete the profile field (commerce_socialmedia.profile) when a socialmedia item is selected in my form? Someone can help me? Is there something already done for my necessity?

Thanks

like image 427
Alessandro Garcez Avatar asked Dec 03 '25 08:12

Alessandro Garcez


1 Answers

i just create a Pull Request with this feature.

In order to use the extra fields functinality you need to pass one extra parameter to the set_relation_n_n function indicating that you want to edit the extra fields

$crud->set_relation_n_n('secialmedia', 'ecommerce_socialmedia', 'socialmedia', 'id', 'id_socialmedia', 'name', null, null, true);

You can also indicate that you don't want to edit one of the extra fields of the relation table by using the unset_edit_fields. You will however be required to prepend the name of the field you wish to exclude, with the string extra_field in order to avoid name conflicts

$crud->unset_edit_fields(array('extra_field_{relation_table_field_name}'));

Follow the link

https://github.com/scoumbourdis/grocery-crud/pull/275

like image 156
LuisComS Avatar answered Dec 05 '25 23:12

LuisComS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!