与sugarcrm中的广告系列模块建立一对多的关系

时间:2014-07-25 11:29:41

标签: php relationship sugarcrm

如何与自定义模块创建一对多关系。并将子面板添加到Campaign模块

Campaign vardefs

$dictionary["Campaign"]["fields"]["costs"] =
    array (
        'name' => 'costs',
        'type' => 'link',
        'relationship' => 'campaign_costs',
        'module'=>'Costs',
        'bean_name'=>'Costs',
        'source'=>'non-db',
        'vname'=>'LBL_AUCTIONS',
    );

$dictionary['Campaign']['relationships']['campaign_costs'] =
    array (
        'lhs_module'=> 'Campaigns',
        'lhs_table'=> 'campaigns',
        'lhs_key' => 'id',
        'rhs_module'=> 'Costs',
        'rhs_table'=> 'cots',
        'rhs_key' => 'campaign_id',
        'relationship_type'=>'one-to-many'
    );

layout_defs属性

$layout_defs["Campaigns"]["subpanel_setup"]["campaign_costs"] = array (
    'order' => 2,
    'module' => 'Costs',
    'subpanel_name' => 'default',
    'sort_order' => 'desc',
    'sort_by' => 'date_entered',
    'title_key' => 'LBL_SUBPANEL_COSTS',
    'get_subpanel_data' => 'costs', //имя поля link
    'top_buttons' =>
        array (
            0 =>
                array (
                    'widget_class' => 'SubPanelTopButtonQuickCreate',
                ),
            1 =>
                array (
                    'widget_class' => 'SubPanelTopSelectButton',
                    'mode' => 'MultiSelect',
                ),
        ),
);

自定义模块vardefs

$dictionary['Costs']['fields']['campaign_id'] =
  array (
      'required' => false,
      'name' => 'campaign_id',
      'vname' => '',
      'type' => 'id',
      'massupdate' => 0,
      'importable' => 'true',
      'audited' => 0,
      'len' => 36,
  );
$dictionary['Costs']['fields']['campaign_name'] =
  array (
      'required' => false,
      'source' => 'non-db',
      'name' => 'campaign_name',
      'vname' => 'LBL_CAMPAIGN_NAME',
      'type' => 'relate',
      'massupdate' => 0,
      'comments' => '',
      'help' => '',
      'audited' => 1,
      'len' => '100',
      'id_name' => 'campaign_id',
      'ext2' => 'Campaigns',
      'module' => 'Campaigns',
      'rname' => 'name',
      'studio' => 'visible',
  );

已添加关系,但子面板未显示在广告系列模块中。

1 个答案:

答案 0 :(得分:0)

$dictionary["Campaign"]["fields"]["costs"]中,将bean_name从Costs更改为Cost

我认为你在管理菜单中启用了子面板? (index.php?module=Administration&action=ConfigureTabs

您的错误日志是否有所说明?