// SubForm field object Zymonic.Field.SubForm = function() {}; // do the inheritance Zymonic.Field.SubForm.prototype = new Zymonic.Field.Field(); Zymonic.Field.SubForm.prototype.constructor = this; // get list of contained fields Zymonic.Field.SubForm.prototype.getFields = function(record) { // get super list of fields var fields = Zymonic.Field.Field.prototype.getFields.call(this); // add all fields from current record if present, otherwise all of the form var got_record = false; if (record) { var form = this.getForm(); if (form) { var record = form.getRecord(record.record_ident); for (var zname in record.field_lookup) { fields.push(record.field_lookup[zname]); } got_record = true; } } if (this.form_ident && !got_record) { getZymonicFieldsByWrapperIdent(this.form_ident).forEach(function(field) { fields.push(field); fields = fields.concat(field.getFields()); }); } return fields; }; Zymonic.Field.SubForm.prototype.setForm = function(zname, ident) { this.form_zname = zname; this.form_ident = ident; }; Zymonic.Field.SubForm.prototype.getForm = function() { if (this.form_ident) { return Zymonic.lookup_object('Form', this.form_ident); } return null; }; // Append to form data Zymonic.Field.SubForm.prototype.appendToForm = function(form_data, search) { // call SUPER Zymonic.Field.Field.prototype.appendToForm.call(this, form_data, search); // add navigation data var form = this.getForm(); if (form) { form.appendNavigationToForm(form_data); } }; // Append other fields to form data Zymonic.Field.SubForm.prototype.appendOtherFieldsToForm = function(form_data, search) { // override the subclass to limit to the current record, if one is set var fields = this.getFields(form_data.record_being_added); for (var i=0; i