Last active
February 9, 2017 22:20
-
-
Save dmulvi/37580d51f58efe7c8e6f to your computer and use it in GitHub Desktop.
SugarCRM 7 - add fields to Full Name headerpane display (middle name, nick name, preferred name etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* I only wanted to apply this change to the Contacts modules so I put this file in: | |
* custom/modules/Contacts/clients/base/fields/fullname/ | |
*/ | |
({ | |
extendsFrom: 'FullnameField', | |
formatMap: { | |
'f': 'first_name', | |
'l': 'last_name', | |
's': 'salutation', | |
'p': 'preferred_name_c', | |
'm': 'middle_name_c' | |
}, | |
initialize: function(options) { | |
// override the name format for this module | |
app.user.setPreference('default_locale_name_format', 's f p m l'); | |
this._super('initialize', [options]); | |
}, | |
format: function() { | |
var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' '; | |
fullname += (!_.isEmpty(this.model.attributes.preferred_name_c)) ? '"'+ this.model.attributes.preferred_name_c +'" ': ' '; | |
fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name; | |
return fullname; | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This is the custom record file for Contacts. | |
* custom/modules/Contacts/clients/base/views/record/record.php | |
*/ | |
<?php | |
$viewdefs['Contacts'] = | |
array ( | |
'base' => | |
array ( | |
'view' => | |
array ( | |
'record' => | |
array ( | |
'buttons' => | |
array ( | |
// .... | |
), | |
'panels' => | |
array ( | |
0 => | |
array ( | |
'name' => 'panel_header', | |
'header' => true, | |
'fields' => | |
array ( | |
0 => | |
array ( | |
'name' => 'picture', | |
'type' => 'avatar', | |
'size' => 'large', | |
'dismiss_label' => true, | |
), | |
// THIS IS THE IMPORTANT PART | |
1 => | |
array ( | |
'name' => 'full_name', | |
'label' => 'LBL_NAME', | |
'dismiss_label' => true, | |
'type' => 'fullname', | |
'fields' => | |
array ( | |
0 => 'salutation', | |
1 => 'first_name', | |
2 => 'preferred_name_c', | |
3 => 'middle_name_c', | |
4 => 'last_name', | |
), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
if you're trying to display the fullname in the subpanel for your updated module and middle_name or | |
another field displays as undefined try the following: | |
open the file: | |
/modules/Contacts/clients/base/views/subpanel-list/subpanel-list.php | |
copy the contents of that file to: | |
/custom/modules/Contacts/clients/base/views/subpanel-list/ | |
edit the fields['full_name'] section as below | |
*/ | |
$viewdefs['Contacts']['base']['view']['subpanel-list'] = array( | |
'type' => 'subpanel-list', | |
'panels' => | |
array( | |
array( | |
'name' => 'panel_header', | |
'label' => 'LBL_PANEL_1', | |
'fields' => array( | |
array( | |
'name' => 'full_name', | |
'type' => 'fullname', | |
'fields' => array( | |
'salutation', | |
'first_name', | |
'last_name', | |
), | |
'link' => true, | |
'label' => 'LBL_LIST_NAME', | |
'enabled' => true, | |
'default' => true, | |
// ADD THIS PART | |
'related_fields' => array( | |
'middle_name_c' | |
), | |
// END OF ADDITION | |
), | |
// the rest of the fields have been removed for brevity, you keep them obviously | |
) | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Below is an example image of how to add the middle_name_c field to the available column in studio for the module. You can find the below configuration in admin > Studio > MODULE_NAME > layouts > list