I have a custom module with two relationships setup. These means i have two relate fields in my custom module. I would like to auto populate the second relate field with the same value as the first relate field.
currently i am trying the following code:
<?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/conn_connection/TextCopy.php', 'textcopy','copy');
?>
class textcopy{
function copy($bean, $event, $arguments)
{
$bean->rece_receiver_conn_connection_1_name = $bean->orga_organisation_conn_connection_1_name;
}
}
This returns a webpage which states the following:
class textcopy{ function copy($bean, $event, $arguments) { $bean->rece_receiever_conn_connection_1_name = $bean->orga_organisation_conn_connection_1_name; } }
Despite these issues i am unsure this will be the solution i would like to use. I would like this field to autopopulate as soon as the first relate field has been selected.
Hi,
I assume you created the file in the location: ‘custom/modules/conn_connection/TextCopy.php’
If not, then you must do this and enter in your code there.
Does your TextCopy.php file have the php tags at the start/end of the file? i.e: <?php[/i][/b] and [b][i] ?>
Hi,
Check your PHP/Apache error Logs, are there any errors in there?
If not, turn on error reporting and see if anything shows on the screen that displays “rece_receiver = $bean->orga_organisation; } } ?>”
What are you using to edit the PHP files? From the screenshot I assume it is Notepad++