define([ "../../widgets/_ComplexValueWidget", "./questions/Factory", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/lang", "dojo/dom-construct", "dojo/text!./templates/SurveyRenderWidget.html" ], function(_ComplexValueWidget, QuestionWidgetFactory, array, declare, lang, domConstruct, template) { return declare([_ComplexValueWidget],{ templateString: template, survey: null, startup: function() { if ( this._started ) { return; } this.inherited(arguments); if ( this.survey ) { this._setSurveyAttr(this.survey); } }, _setSurveyAttr: function(survey) { domConstruct.empty(this.domNode); this.survey = survey; var f = new QuestionWidgetFactory(); array.forEach(this.survey.questions,function(question){ array.forEach(question.content || [], function(item){ item.code = question.code; var w = f.createViewWidget(item); if ( w !== null ) { w.placeAt(this.domNode); w.startup(); } },this); },this); }, _getValueAttr: function() { var newValue = {}; array.forEach(this._getDescendantFormWidgets(),function(widget){ lang.mixin(newValue,widget.get('value')); },this); return newValue; }, _setValueAttr: function(value,priorityChange) { this._setValueInternal(value,priorityChange); array.forEach(this._getDescendantFormWidgets(),function(widget){ widget.set('value',value); },this); } }); });