dpbf62565 2013-10-30 23:02
浏览 74
已采纳

如何使用PHP修改SugarCRM SubPanel的数据?

Is there anyway to modify the content shown in a SugarCRM Subpanel without relying on Action Hooks?

Right now to edit content for a Subpanel field I have to use the hooks like this...

$hook_array['process_record']

And in the Class method that I assign the Hook to call I can then change a field in the Subpanel like this...

$bean->name = '<a href="/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3Dproje_Web_Project_Tasks%26action%3DDetailView%26record%3D'
.$bean->id.'" rel="popover" data-content="'
.$bean->description.'" data-original-title="">'.$bean->name.'</a>';

The main and major problem we have with this method is it works great until you do either of these actions....

  1. Add an item using the Quick Create form
  2. Change a page using the Subpanel paging buttons

In either case, it reloads the Subpanel data without running this hook code on the data, so the result is pretty major as the Subpanel fields that you have edited are no longer edited and show up as normal.

Here is a basic example...this shows 2-3 fields that have been edited using the Hook method above...
enter image description here

Now after paging or quick-creating a new record in the Subpanel, it reloads the Subpanel data and does not apply the Hooked code so you can see the result looks like this...
enter image description here

I know that ListView has a much more reliable and flexible method for editing it's content using the get_list_view_data() method I am able to apply the same edits and have them work all the time!

So I am hoping there is a similar method to edit Subpanel data and have it always apply the edits to that data? From what I have seen in my research so far, the only solution that will work as expected all the time, is to make a completely new Custom Field Type!

I am really hoping that is not the ONLY way as that is a major pain to do that for each type of field that I need to edit in the Subpanels and just doesn't feel right when there are easy ways to edit everything else except SubPanel data.

Does anyone have any ideas, suggestions, tips, help, please do share with me on this matter as it is the main problem I have had since I started developing with SugarCRM in the past few months?

  • 写回答

1条回答 默认 最新

  • duanjuan1103 2013-11-29 14:25
    关注

    You can change the data by writing a custom query to get data for your subpanel.

    So inside your bean (this case Contacts) do a functions:

    function get_project_list() {
       $query = "SELECT project, info, matching, column, names FROM projects WHERE contact_id = '" . $this->id . "' AND deleted = 0"
       return $query;
    }
    

    and then in subpanel definition set the data source like this:

    $layout_defs["Contacts"]["subpanel_setup"]['projects'] = array(
            'order' => 10,
            'sort_order' => 'desc',
            'sort_by' => 'name',
            'title_key' => 'LBL_PROJECTS_TITLE',
            'subpanel_name' => 'contact_projects',
            'module'=>'projects',
            'get_subpanel_data' => 'function:get_project_list',
            'function_parameters'=>array('type'=>'urgent'), // this is optional if you decide to sent parameters to the function if do this dont forget to define your function with function get_project_list($params)
            'top_buttons' => array (... buttons that you need go here..),
    );
    

    Since sql is quite powerful you can modify your subpanel data any way you like, well more or less :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体