自定义模块子面板

发布于 2024-11-09 13:26:32 字数 1938 浏览 0 评论 0原文

所以我有两个自定义模块。它们是一对多相关的。 模块 A vardef 具有:`'lm_contacts' =>

array(
  'name' => 'lm_contacts',
  'type' => 'link',
  'relationship' => 'lm_contacts_relation',
  'source' => 'non-db',
  'vname' => 'LBL_LEADS',
),

'relationships' => 
array (
        'lm_contacts_relation' => 
        array (
            'lhs_module' => 'LM_LM_Objektas',
            'lhs_table' => 'lm_lm_objektas',
            'lhs_key' => 'id',
            'rhs_module' => 'LM_LM_contact_person',
            'rhs_table' => 'lm_lm_contact_person',
            'rhs_key' => 'lm_object ',
            'relationship_type' => 'one-to-many',
          ),
      ),

并且模块 a 有 subpaneldef:

$layout_defs['LM_LM_Objektas'] = array(
// list of what Subpanels to show in the DetailView
    'subpanel_setup' => 
    array(
        'lm_contacts' => 
        array(
            'order' => 10,
            'module' => 'LM_LM_contact_person',
            'subpanel_name' => 'default',
            'sort_order' => 'asc',
            //'sort_by' => 'id',
            'title_key' => 'LBL_CONTACT_SUBPANEL_TITLE',
            'get_subpanel_data' => 'lm_contacts',
            'add_subpanel_data' => 'lm_contacts_id',
            'top_buttons' => 
            array (
                0 => 
                array (
                    'widget_class' => 'SubPanelTopButtonQuickCreate',
                ),
                1 => 
                array (
                    'widget_class' => 'SubPanelTopSelectButton',
                    'mode' => 'MultiSelect',
                    'popup_module' => 'LM_LM_contact_person',
                ),
            ),
        ),
),
);

现在模块 a:lm_objectas 确实显示子面板,但是当我尝试通过子面板快速创建按钮将新的 reqord 添加到 lm_contacts 模块时,记录确实创建,但没有字段“'rhs_key'=>”的关系数据“lm_object”已创建。因此,子面板上自然不会显示任何新记录。 我缺少什么? 谢谢!

So I have two custom modules. they are related one-to-many.
Module A vardef has:`'lm_contacts' =>

array(
  'name' => 'lm_contacts',
  'type' => 'link',
  'relationship' => 'lm_contacts_relation',
  'source' => 'non-db',
  'vname' => 'LBL_LEADS',
),

'relationships' => 
array (
        'lm_contacts_relation' => 
        array (
            'lhs_module' => 'LM_LM_Objektas',
            'lhs_table' => 'lm_lm_objektas',
            'lhs_key' => 'id',
            'rhs_module' => 'LM_LM_contact_person',
            'rhs_table' => 'lm_lm_contact_person',
            'rhs_key' => 'lm_object ',
            'relationship_type' => 'one-to-many',
          ),
      ),

and module a has subpaneldef:

$layout_defs['LM_LM_Objektas'] = array(
// list of what Subpanels to show in the DetailView
    'subpanel_setup' => 
    array(
        'lm_contacts' => 
        array(
            'order' => 10,
            'module' => 'LM_LM_contact_person',
            'subpanel_name' => 'default',
            'sort_order' => 'asc',
            //'sort_by' => 'id',
            'title_key' => 'LBL_CONTACT_SUBPANEL_TITLE',
            'get_subpanel_data' => 'lm_contacts',
            'add_subpanel_data' => 'lm_contacts_id',
            'top_buttons' => 
            array (
                0 => 
                array (
                    'widget_class' => 'SubPanelTopButtonQuickCreate',
                ),
                1 => 
                array (
                    'widget_class' => 'SubPanelTopSelectButton',
                    'mode' => 'MultiSelect',
                    'popup_module' => 'LM_LM_contact_person',
                ),
            ),
        ),
),
);

Now module a: lm_objectas does display subpanel corectly, but when i try to add new reqord to lm_contacts module trough subpanel quick create button, record does create, but no realation data of field " 'rhs_key' => 'lm_object' " is created. so naturaly no new record on subpanle does get displayed.
What I am missing?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风吹 2024-11-16 13:26:32

抱歉回复晚了,但我可以解释一下:

你没有做错任何事,这是我在 Sugar 中发现的一个错误......

从快速创建创建的记录与你所在的活动记录相关的原因是因为快速创建按钮有一个隐藏表单,其中当前记录的 id 映射到子面板模块用于该关系的字段。但是,当您创建自定义模块时,快速创建假定相关字段将为“moduleA_moduleB_id”,它适用于 Sugar 中的库存模块。但是,当您在 Sugar 中创建自定义模块时,它会截断所有关系字段(在 Bean 中和数据库中),以便它们不超过 25 个字符。

长话短说,快速创建代码假设将两者链接在一起的字段将具有与库存模块关系相同的约定,这是错误的。

在不修复代码(或等待 Sugar 的错误修复)的情况下避免这种情况的唯一方法是确保您的自定义模块的名称少于 10 个字符,包括它放在前面的密钥(所以实际上应该是最多 5-6 个字符)。

我已经更新了我自己安装的 Sugar 中的代码并报告了该错误。它可能会在下次更新中修复。

我会解释如何在您的库存实例中修复它,但恐怕这只会让事情变得更加混乱。但如果您仍然需要解决此问题,请告诉我,我将发布实际的代码。

Sorry for the late response, but I can explain:

You are not doing anything wrong, this is a bug I discovered in Sugar....

The reason why the record created from the quick create is related to the active record you are on is because the quick create button has a hidden form with the id of the current record mapped to the field that the subpanel module uses for that relationship. But when you create a custom module, the quick create assumes that the relate field will be "moduleA_moduleB_id", which it is for the stock modules in Sugar. But when you create a custom module in Sugar, it truncates all relationship fields (in the Bean and in the database) so that they are not over 25 characters.

Long story short, the quick create code assumes that the field that links the two together will have the same convention as the stock module relationships, which is wrong.

The only way to avoid this without fixing the code (or waiting for Sugar's bug fix), is to make sure that your custom module has a name less than 10 characters, including the key that it puts on the front (so really it should be 5-6 characters tops).

I've updated the code in my own install of Sugar and have reported the bug. It may be fixed in the next update.

I'd explain how to fix it in your stock instance, but I'm afraid that would only confuse matters more. But let me know if you still need to fix this, and I'll post the actual code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文