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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?