Skip to content

Instantly share code, notes, and snippets.

@elchele
Created October 15, 2014 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchele/871a0b2d87fb24e67376 to your computer and use it in GitHub Desktop.
Save elchele/871a0b2d87fb24e67376 to your computer and use it in GitHub Desktop.
Custom controller for setting a default value on a field upon record creation
({
/* file: ./custom/modules/Accounts/clients/base/views/create-actions/create-actions.js */
extendsFrom: 'CreateView',
initialize: function(options){
this._super('initialize', [options]);
/* this is where I set the default value for a given field, in this case
it is the value 'Angel Inc.' to the 'name' field in the Accounts module.
How one derives the value is irrelevant and can involve querying another system,
a custom endpoint on the Sugar API or a static value, as in this case.
*/
var myDefaultValue = 'Angel Inc.';
this.model.set('name', myDefaultValue);
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment