Skip to content
Snippets Groups Projects
Commit 8fd0e719 authored by colemanw's avatar colemanw
Browse files

Profile editor: Fetch pre/post help for custom fields

parent 9c6added
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@
* @return {CRM.UF.UFFieldModel} or null (if the field is not addable)
*/
addToUFCollection: function(ufFieldCollection, addOptions) {
var paletteFieldModel = this;
var name, paletteFieldModel = this;
var ufFieldModel = paletteFieldModel.createUFFieldModel(ufFieldCollection.getRel('ufGroupModel'));
ufFieldModel.set('uf_group_id', ufFieldCollection.uf_group_id);
if (!ufFieldCollection.isAddable(ufFieldModel)) {
......@@ -55,6 +55,14 @@
return null;
}
ufFieldCollection.add(ufFieldModel, addOptions);
// Load metadata and set defaults
// TODO: currently only works for custom fields
name = this.get('fieldName').split('_');
if (name[0] === 'custom') {
CRM.api('custom_field', 'getsingle', {id: name[1]}, {success: function(field) {
ufFieldModel.set(field);
}});
}
return ufFieldModel;
},
createUFFieldModel: function(ufGroupModel) {
......
......@@ -678,11 +678,17 @@
fields: fields
});
this.form.on('change', this.onFormChange, this);
this.model.on('change', this.onModelChange, this);
},
render: function() {
this.$el.html(this.form.render().el);
this.onFormChange();
},
onModelChange: function() {
$.each(this.form.fields, function(i, field) {
this.form.setValue(field.key, this.model.get(field.key));
});
},
onFormChange: function() {
this.form.commit();
this.$('.field-is_multi_summary').toggle(this.options.fieldSchema.civiIsMultiple ? true : false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment