Skip to content

Instantly share code, notes, and snippets.

@elchele elchele/record.js
Created Nov 18, 2014

What would you like to do?
Custom controller for RecordView, demonstrates dynamic required fields based on current user
/* Author: Angel Magaña --
* 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;

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.