简体   繁体   English

Grocery CRUD relation n_n - 如何在关系表中完成其他字段

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

I have an application where I use Codeigniter + Grocery CRUD. 我有一个应用程序,我使用Codeigniter + Grocery CRUD。

I was making a "n_n" relation , but in table that store the relation there is a third field. 我正在建立一个“n_n”关系,但是在存储关系的表中有第三个字段。

Bellow my DB structure: Bellow我的数据库结构:

在此输入图像描述

Grocery CRUD allows me to select the socialmedia as displayed bellow: Grocery CRUD允许我选择如下所示的社交媒体:

在此输入图像描述

The complete functionality is showed here: http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n 完整功能如下所示: 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? 如何在表单中选择社交媒体项目时,如何填写个人资料字段(commerce_socialmedia.profile)? Someone can help me? 有人可以帮帮我吗? Is there something already done for my necessity? 我的必需品已经做了些什么吗?

Thanks 谢谢

i just create a Pull Request with this feature. 我只是使用此功能创建一个Pull Request。

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 为了使用额外的字段功能,您需要将一个额外的参数传递给set_relation_n_n函数,指示您要编辑额外的字段

$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. 您还可以通过使用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 但是,您需要在字段extra_field之前添加要排除的字段的名称,以避免名称冲突

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

Follow the link 点击链接

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM