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