Reputation: 85
I am trying to copy one field into another. One is a related field called Members and the other is called Name.
I believe doing this with Logic Hooks is the best way. So below is my 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');
?>
And here is my.php
class User_hook {
function copy(&$bean, $event, $arguments)
{
$bean->name = $bean->member;
}
}
Here is the error I get on save
class User_hook { function copy(&$bean, $event, $arguments) { $bean->name = $bean->member; } }
Upvotes: 1
Views: 1076
Reputation: 443
It causes problems to use &$bean
in recent versions of sugarCRM. $bean
is already passed by reference. In the arguments for function copy
, change &$bean
to just $bean
.
Upvotes: 1