Skip to content

Instantly share code, notes, and snippets.

@elchele
Created November 18, 2014 01:14
Show Gist options
  • Save elchele/de33eb619464716bb81e to your computer and use it in GitHub Desktop.
Save elchele/de33eb619464716bb81e to your computer and use it in GitHub Desktop.
Custom controller for RecordView, demonstrates dynamic required fields based on current user
({
/* Author: Angel Magaña -- [email protected]
* File: ./custom/modules/<Module>/clients/base/views/record/record.js
*
* Custom controller for RecordView demonstrating dynamic required attribute
* (leads module is used for the example)
*/
extendsFrom: 'RecordView',
initialize: function(options){
this._super('initialize', [options]);
//Here we check the user name for the currenlty logged in user
if (app.user.get('user_name') === 'SomeUser')
{
/* Set the "required" attribute to true on the 'title' field
on the Leads field for user "SomeUser" */
this.model.fields['title']['required'] = true;
}
},
})
@elchele
Copy link
Author

elchele commented Nov 18, 2014

If you need to apply this customization to the process of creating a record, do the following:

  1. Change extendsFrom: 'RecordView', to extendsFrom: 'CreateView',
  2. Create the file as create-actions.js and place in ./custom/modules//clients/base/views/create-actions/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment