/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.form.manager._ValueMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.form.manager._ValueMixin"] = true;
dojo.provide("dojox.form.manager._ValueMixin");
dojo.declare("dojox.form.manager._ValueMixin", null, {
// summary:
// Form manager's mixin for getting/setting form values in the unified manner.
// description:
// This mixin adds unified access to form widgets and form elements
// in terms of name-value regardless of the underlying type of
// an element. It should be used together with dojox.form.manager.Mixin.
elementValue: function(name, value){
// summary:
// Set or get a form widget/element or an attached point node by name.
// name: String:
// The name.
// value: Object?:
// Optional. The value to set.
if(name in this.formWidgets){
return this.formWidgetValue(name, value); // Object
}
if(this.formNodes && name in this.formNodes){
return this.formNodeValue(name, value); // Object
}
return this.formPointValue(name, value); // Object
},
gatherFormValues: function(names){
// summary:
// Collect form values.
// names: Object?:
// If it is an array, it is a list of names of form elements to be collected.
// If it is an object, dictionary keys are names to be collected.
// If it is omitted, all known form elements are to be collected.
var result = this.inspectFormWidgets(function(name){
return this.formWidgetValue(name);
}, names);
if(this.inspectFormNodes){
dojo.mixin(result, this.inspectFormNodes(function(name){
return this.formNodeValue(name);
}, names));
}
dojo.mixin(result, this.inspectAttachedPoints(function(name){
return this.formPointValue(name);
}, names));
return result; // Object
},
setFormValues: function(values){
// summary:
// Set values to form elements
// values: Object:
// A dictionary of key-value pairs.
if(values){
this.inspectFormWidgets(function(name, widget, value){
this.formWidgetValue(name, value);
}, values);
if(this.inspectFormNodes){
this.inspectFormNodes(function(name, node, value){
this.formNodeValue(name, value);
}, values);
}
this.inspectAttachedPoints(function(name, node, value){
this.formPointValue(name, value);
}, values);
}
return this;
}
});
}