Hello,
I want to add middle name record view header pane in contact module.
Ramana Raju Santhana Francesca Shiekh Alan Apter
Thanks
Dipesh
Hello,
I want to add middle name record view header pane in contact module.
Ramana Raju Santhana Francesca Shiekh Alan Apter
Thanks
Dipesh
I believe you will need to customize both the fullname feld type:
clients/base/fields/fullname
and the Contacts record view php
array(
'name' => 'full_name',
'label' => 'LBL_NAME',
'dismiss_label' => true,
'type' => 'fullname',
'fields' => array('salutation', 'first_name', 'last_name'),
),
HTH
Francescas
Hi Francesca Shiekh & Ajay Kumar
It is work for me in Record edit view. When I save middle name, it is saved with database. But I have load record view page at that time middle name is undefined display.
List page
Record view page
Thanks
HiFrancesca Shiekh ,
custom/modules/Contacts/clients/base/fields/fullname/fullname.js
/*
* 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',
'm': 'middle_name_c'
},initialize: function(options) {
// override the name format for this module
app.user.setPreference('default_locale_name_format', 's f m l');this._super('initialize', [options]);
},format: function() {
var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' ';
fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name;return fullname;
},
})
It display with middle name.
When I will save record, It will store with Database.
Thanks
Hi Bao Tran Hoang,
Can you customize record-edit.hbs.
clients/base/fields/fullname/record-edit.hbs
{{#each fields}}
<span class="record-cell{{#if span}} span{{span}}{{/if}}" data-name="{{name}}" data-type="{{type}}">
{{#unless dismiss_label}}
<div class="record-label" data-name="{{name}}">{{str label ../../../module}}</div>
{{/unless}}
<span data-fieldname="{{name}}" style="width:30%">
{{placeholder}}
</span>
</span>
{{/each}}
Thank for your reply Roland Cadavos,
It does not work with me,
My code:
.record-cell[data-name="middle_name_c"]{
width: 10em !important;
}
.record-cell[data-name="suffix_c"]{
width: 10em !important;
}
I have same issue.
Hi Bao Tran Hoang,
Please can you explain me, how it's come full name ?
Hi Offshore Evolution
You add middle_name_c in Available column of Listview in studio
Also check your config, I just noticed that there is a
'default_locale_name_format' => 's f l' //salutation first last
Yes it is working with list view page.
How does it work with record view and edit record view ?
Hi Francesca Shiekh,
I have already set file, custom/modules/Contacts/clients/base/fields/fullname/fullname.js
/*
* 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',
'm': 'middle_name_c'
},
initialize: function(options) {
// override the name format for this module
app.user.setPreference('default_locale_name_format', 's f m l');
this._super('initialize', [options]);
},
format: function() {
var fullname = this.model.attributes.salutation +' '+ this.model.attributes.first_name +' ';
fullname += this.model.attributes.middle_name_c +' '+ this.model.attributes.last_name;
return fullname;
},
})
But main issue is this.model.attributes.middle_name_c is blank.
I've not tried this myself but I don't think you need to override the format Name Model function, just pass an extra variable to specify the format you want.
If you look at the app.utils.formatNameModel function in sidecar/src/utils/utils.js
You will see that you can pass the format you want to override the user format:
formatNameModel: function(module, data, format) {
format = format || app.user.getPreference('default_locale_name_format');
So I would try redefining your format function:
format: function() {
var format = 's f m l';
return app.utils.formatNameModel(this.model.module, this.model.attributes, format);
},
The formatNameModel function should do all the work for you based on the format you are passing.
See if that works.
In general, to get the attributes' values I use this.model.get('<attribute name>'):
this.model.get('middle_name_c');
And to set them use this.model.set('<attribute name>', '<attribute value>');
this.model.set('middle_name_c', 'Carols');
HTH
FrancescaS
You add custom/modules/Contacts/clients/base/fields/fullname/fullname.js
({ | |
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; | |
}, | |
}) |
You add custom/modules/Contacts/clients/base/fields/fullname/fullname.js
({ | |
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; | |
}, | |
}) |