2015-04-17 66 views
1

我試圖將一個字段複製到另一個字段。一個是名爲Members的相關字段,另一個名爲Name。通過Logic Hook的Sugarcrm/Suitecrm複製字段

我相信用Logic Hooks這樣做是最好的方法。所以,下面是我的logic_hooks.php

<?php 
    // Do not store anything in this file that is not part of the array or the hook version. This file will  
    // be automatically rebuilt in the future. 
    $hook_version = 1; 
    $hook_array = Array(); 
    // position, file, function 
    $hook_array['before_save'] = Array(); 
    $hook_array['before_save'][] = Array(1, 'Value from one field to another', 'custom/modules/ship_Membership/my.php', 'User_hook','copy'); 
?> 

這裏是my.php

class User_hook { 

    function copy(&$bean, $event, $arguments) 
    { 

    $bean->name = $bean->member; 
    } 

} 

以下是錯誤我得到保存

class User_hook { function copy(&$bean, $event, $arguments) { $bean->name = $bean->member; } } 
+0

您發佈的錯誤似乎是User_hook類,是故意的嗎? – Jim

+0

也許您需要刪除類名稱中的下劃線(UserHook而不是User_hook)。另外,嘗試將&$ bean更改爲$ bean。 – LaurentH

回答

1

它會導致問題,在最近使用&$bean sugarCRM的版本。 $bean已通過引用傳遞。在function copy的參數中,將&$bean更改爲$bean