2 var CRM
= (window
.CRM
) ? (window
.CRM
) : (window
.CRM
= {});
3 if (!CRM
.Schema
) CRM
.Schema
= {};
6 * Civi data models require more attributes than basic Backbone models:
7 * - sections: array of field-groupings
8 * - schema: array of fields, keyed by field name, per backbone-forms
10 * @see https://github.com/powmedia/backbone-forms
13 CRM
.Schema
.IndividualModel
= CRM
.Backbone
.Model
.extend({
15 'default': {title
: 'Individual'},
16 'custom1': {title
: 'Individual: Favorite Things', is_addable
: true},
17 'custom2': {title
: 'Individual: Custom Things', is_addable
: true}
20 first_name
: { type
: 'Text', title
: 'First name', civiFieldType
: 'Individual' },
21 last_name
: { type
: 'Text', title
: 'Last name', civiFieldType
: 'Individual' },
22 legal_name
: { type
: 'Text', title
: 'Legal name', civiFieldType
: 'Contact' },
23 street_address
: { validators
: ['required', 'email'], title
: 'Email', civiFieldType
: 'Contact', civiIsLocation
: true, civiIsPhone
: false },
24 email
: { validators
: ['required', 'email'], title
: 'Email', civiFieldType
: 'Contact', civiIsLocation
: true, civiIsPhone
: true },
25 custom_123
: { type
: 'Checkbox', section
: 'custom1', title
: 'Likes whiskers on kittens', civiFieldType
: 'Individual'},
26 custom_456
: { type
: 'Checkbox', section
: 'custom1', title
: 'Likes dog bites', civiFieldType
: 'Individual' },
27 custom_789
: { type
: 'Checkbox', section
: 'custom1', title
: 'Likes bee stings', civiFieldType
: 'Individual' },
28 custom_012
: { type
: 'Text', section
: 'custom2', title
: 'Pass phrase', civiFieldType
: 'Contact' }
30 initialize: function() {
35 CRM
.Schema
.ActivityModel
= CRM
.Backbone
.Model
.extend({
37 'default': {title
: 'Activity'},
38 'custom3': {title
: 'Activity: Questions', is_addable
: true}
41 subject
: { type
: 'Text', title
: 'Subject', civiFieldType
: 'Activity' },
42 location
: { type
: 'Text', title
: 'Location', civiFieldType
: 'Activity' },
43 activity_date_time
: { type
: 'DateTime', title
: 'Date-Time', civiFieldType
: 'Activity' },
44 custom_789
: { type
: 'Select', section
: 'custom3', title
: 'How often do you eat cheese?',
45 options
: ['Never', 'Sometimes', 'Often'],
46 civiFieldType
: 'Activity'
49 initialize: function() {