SugarCRM: encoding a custom middle name field

I am trying to create a custom field in SugarOS 6 to store middle names. Designing and implementing a field in EditView was fairly simple with Studio. But I got stuck when it came to displaying parts of the concatenated name in the DetailView (i.e. Greeting + First Name + Middle Name + Last Name ).

Forming through Sugar forums has drawn me to this topic , which describes how to do it. I implemented the code here as a Sugar logical hook that uses the after_retrieve hook that gets called when the record is loaded.

Here is my hook code:

$hook_array['after_retrieve'] = Array(); 
$hook_array['after_retrieve'][] = array(
        100, 
        'set_full_name', 
        'custom/modules/Leads/leads_custom_logic.php', 
        'LeadsCustomLogic', 
        'setFullName'
);

And here is the function that is called:

function setFullName( &$focus, $event, $arguments ) {
    $name = $focus->salutation . ' ' . 
            $focus->first_name . ' ' .
            ( $focus->middle_name_c ? ( $focus->middle_name_c . ' ' ) : '' ) . 
            $focus->last_name;
    $focus->name = $name;
    $focus->full_name = $name;
    // echo $focus->full_name;
}  

, (), (, ). , , .. DetailView, .

?

, ^

+3
1

detailview.php defs

'customCode' => '{$fields.salutation.value} {$fields.first_name.value} {$fields.midle_name_c.value} {$fields.last_name.value}'

key => value, full_name .

+1

Source: https://habr.com/ru/post/1774070/


All Articles