2 * Dynamically-generated alternative to civi.core.js
5 var CRM
= (window
.CRM
) ? (window
.CRM
) : (window
.CRM
= {});
6 if (!CRM
.Schema
) CRM
.Schema
= {};
9 * Data models used by the Civi form designer require more attributes than basic Backbone models:
10 * - sections: array of field-groupings
11 * - schema: array of fields, keyed by field name, per backbone-forms; extra attributes:
12 * + section: string, index to the 'sections' array
13 * + civiFieldType: string
15 * @see https://github.com/powmedia/backbone-forms
18 CRM
.Schema
.BaseModel
= CRM
.Backbone
.Model
.extend({
19 initialize: function() {
23 CRM
.Schema
.loadModels = function(civiSchema
) {
24 _
.each(civiSchema
, function(value
, key
, list
) {
25 CRM
.Schema
[key
] = CRM
.Schema
.BaseModel
.extend(value
);
29 CRM
.Schema
.reloadModels = function(options
) {
32 url
: CRM
.url("civicrm/profile-editor/schema"),
34 'entityTypes': _
.keys(CRM
.civiSchema
).join(',')
38 success: function(data
) {
40 CRM
.civiSchema
= data
;
41 CRM
.Schema
.loadModels(CRM
.civiSchema
);
47 CRM
.Schema
.loadModels(CRM
.civiSchema
);