source: [view]
define("dijit/form/Form", ["dojo", "dijit", "dijit/_Widget", "dijit/_Templated", "dijit/form/_FormMixin", "dijit/layout/_ContentPaneResizeMixin"], function(dojo, dijit) {
dojo.declare(
"dijit.form.Form",
[dijit._Widget, dijit._Templated, dijit.form._FormMixin, dijit.layout._ContentPaneResizeMixin],
{
// summary:
// Widget corresponding to HTML form tag, for validation and serialization
//
// example:
// |
// | myObj = {name: "John Doe"};
// | dijit.byId('myForm').set('value', myObj);
// |
// | myObj=dijit.byId('myForm').get('value');
// HTML ",
attributeMap: dojo.delegate(dijit._Widget.prototype.attributeMap, {
action: "",
method: "",
encType: "",
"accept-charset": "",
accept: "",
target: ""
}),
postMixInProperties: function(){
// Setup name=foo string to be referenced from the template (but only if a name has been specified)
// Unfortunately we can't use attributeMap to set the name due to IE limitations, see #8660
this.nameAttrSetting = this.name ? ("name='" + this.name + "'") : "";
this.inherited(arguments);
},
execute: function(/*Object*/ formContents){
// summary:
// Deprecated: use submit()
// tags:
// deprecated
},
onExecute: function(){
// summary:
// Deprecated: use onSubmit()
// tags:
// deprecated
},
_setEncTypeAttr: function(/*String*/ value){
this.encType = value;
dojo.attr(this.domNode, "encType", value);
if(dojo.isIE){ this.domNode.encoding = value; }
},
postCreate: function(){
// IE tries to hide encType
// TODO: remove in 2.0, no longer necessary with data-dojo-params
if(dojo.isIE && this.srcNodeRef && this.srcNodeRef.attributes){
var item = this.srcNodeRef.attributes.getNamedItem('encType');
if(item && !item.specified && (typeof item.value == "string")){
this.set('encType', item.value);
}
}
this.inherited(arguments);
},
reset: function(/*Event?*/ e){
// summary:
// restores all widget values back to their init values,
// calls onReset() which can cancel the reset by returning false
// create fake event so we can know if preventDefault() is called
var faux = {
returnValue: true, // the IE way
preventDefault: function(){ // not IE
this.returnValue = false;
},
stopPropagation: function(){},
currentTarget: e ? e.target : this.domNode,
target: e ? e.target : this.domNode
};
// if return value is not exactly false, and haven't called preventDefault(), then reset
if(!(this.onReset(faux) === false) && faux.returnValue){
this.inherited(arguments, []);
}