dijit/form/Form.js

  • Provides:

    • dijit.form.Form
  • dijit.form.Form

    • type
      Function
    • chains:
      • dijit._Widget: (prototype)
      • dijit._Widget: (call)
      • dijit._Templated: (call)
      • dijit.form._FormMixin: (call)
      • dijit.layout._ContentPaneResizeMixin: (call)
    • mixins:
      • dijit._Templated.prototype: (prototype)
      • dijit.form._FormMixin.prototype: (prototype)
      • dijit.layout._ContentPaneResizeMixin.prototype: (prototype)
    • summary
      Widget corresponding to HTML form tag, for validation and serialization
  • dijit.form.Form.name

    • summary
  • dijit.form.Form.action

    • type
      String
    • summary
      Server-side form handler.
  • dijit.form.Form.method

    • type
      String
    • summary
      HTTP method used to submit the form, either "GET" or "POST".
  • dijit.form.Form.encType

    • type
      String
    • summary
      Encoding type for the form, ex: application/x-www-form-urlencoded.
  • dijit.form.Form.accept-charset

    • type
      String
    • summary
      List of supported charsets.
  • dijit.form.Form.accept

    • type
      String
    • summary
      List of MIME types for file upload.
  • dijit.form.Form.target

    • type
      String
    • summary
      Target frame for the document to be opened in.
  • dijit.form.Form.templateString

    • summary
  • dijit.form.Form.attributeMap

    • summary
  • dijit.form.Form.postMixInProperties

    • type
      Function
    • 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:
        // | 

        // |  Name:
        // | 

        // | myObj = {name: "John Doe"};
        // | dijit.byId('myForm').set('value', myObj);
        // |
        // | myObj=dijit.byId('myForm').get('value');


        // HTML
      attributes


        // name: String?
        //  Name of form for scripting.
        name: "",


        // action: String?
        //  Server-side form handler.
        action: "",


        // method: String?
        //  HTTP method used to submit the form, either "GET" or "POST".
        method: "",


        // encType: String?
        //  Encoding type for the form, ex: application/x-www-form-urlencoded.
        encType: "",


        // accept-charset: String?
        //  List of supported charsets.
        "accept-charset": "",


        // accept: String?
        //  List of MIME types for file upload.
        accept: "",


        // target: String?
        //  Target frame for the document to be opened in.
        target: "",


        templateString: "
      ",


        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);
    • summary
  • dijit.form.Form.execute

    • type
      Function
    • parameters:
      • formContents: (typeof Object)
    • source: [view]
         // summary:
         //  Deprecated: use submit()
         // tags:
         //  deprecated
    • summary
      Deprecated: use submit()
    • tags:
  • dijit.form.Form.onExecute

    • type
      Function
    • source: [view]
         // summary:
         //  Deprecated: use onSubmit()
         // tags:
         //  deprecated
    • summary
      Deprecated: use onSubmit()
    • tags:
  • dijit.form.Form._setEncTypeAttr

    • type
      Function
    • parameters:
      • value: (typeof String)
    • source: [view]
         this.encType = value;
         dojo.attr(this.domNode, "encType", value);
         if(dojo.isIE){ this.domNode.encoding = value; }
    • summary
  • dijit.form.Form.postCreate

    • type
      Function
    • 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:
        // | 

        // |  Name:
        // | 

        // | myObj = {name: "John Doe"};
        // | dijit.byId('myForm').set('value', myObj);
        // |
        // | myObj=dijit.byId('myForm').get('value');


        // HTML
      attributes


        // name: String?
        //  Name of form for scripting.
        name: "",


        // action: String?
        //  Server-side form handler.
        action: "",


        // method: String?
        //  HTTP method used to submit the form, either "GET" or "POST".
        method: "",


        // encType: String?
        //  Encoding type for the form, ex: application/x-www-form-urlencoded.
        encType: "",


        // accept-charset: String?
        //  List of supported charsets.
        "accept-charset": "",


        // accept: String?
        //  List of MIME types for file upload.
        accept: "",


        // target: String?
        //  Target frame for the document to be opened in.
        target: "",


        templateString: "
      ",


        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);
    • summary
  • dijit.form.Form.reset

    • type
      Function
    • parameters:
      • e: (typeof Event)
    • 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:
        // | 

        // |  Name:
        // | 

        // | myObj = {name: "John Doe"};
        // | dijit.byId('myForm').set('value', myObj);
        // |
        // | myObj=dijit.byId('myForm').get('value');


        // HTML
      attributes


        // name: String?
        //  Name of form for scripting.
        name: "",


        // action: String?
        //  Server-side form handler.
        action: "",


        // method: String?
        //  HTTP method used to submit the form, either "GET" or "POST".
        method: "",


        // encType: String?
        //  Encoding type for the form, ex: application/x-www-form-urlencoded.
        encType: "",


        // accept-charset: String?
        //  List of supported charsets.
        "accept-charset": "",


        // accept: String?
        //  List of MIME types for file upload.
        accept: "",


        // target: String?
        //  Target frame for the document to be opened in.
        target: "",


        templateString: "
      ",


        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, []);
         }
    • returns
      the IE way
    • summary
  • dijit.form.Form.onReset

    • type
      Function
    • parameters:
      • e: (typeof Event)
    • source: [view]
         return true; // Boolean
    • summary
      Callback when user resets the form. This method is intended
      to be over-ridden. When the `reset` method is called
      programmatically, the return value from `onReset` is used
      to compute whether or not resetting should proceed
    • tags:
    • returns
      Boolean
  • dijit.form.Form._onReset

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         this.reset(e);
         dojo.stopEvent(e);
         return false;
    • summary
  • dijit.form.Form._onSubmit

    • type
      Function
    • parameters:
      • e: (typeof )
    • source: [view]
         var fp = dijit.form.Form.prototype;
         // TODO: remove this if statement beginning with 2.0
         if(this.execute != fp.execute || this.onExecute != fp.onExecute){
          dojo.deprecated("dijit.form.Form:execute()/onExecute() are deprecated. Use onSubmit() instead.", "", "2.0");
          this.onExecute();
          this.execute(this.getValues());
         }
         if(this.onSubmit(e) === false){ // only exactly false stops submit
          dojo.stopEvent(e);
         }
    • summary
  • dijit.form.Form.onSubmit

    • type
      Function
    • parameters:
      • e: (typeof Event)
    • source: [view]
         return this.isValid(); // Boolean
    • summary
      Callback when user submits the form.
    • description
      This method is intended to be over-ridden, but by default it checks and
      returns the validity of form elements. When the `submit`
      method is called programmatically, the return value from
      `onSubmit` is used to compute whether or not submission
      should proceed
    • tags:
    • returns
      Boolean
  • dijit.form.Form.submit

    • type
      Function
    • source: [view]
         if(!(this.onSubmit() === false)){
          this.containerNode.submit();
         }
    • summary
      programmatically submit form if and only if the `onSubmit` returns true
  • dijit.form.Form.nameAttrSetting

    • summary
  • dijit.form.Form.domNode.encoding

    • summary
  • dijit.form.Form.returnValue

    • summary
  • dijit.form

    • type
      Object
    • summary
  • dijit

    • type
      Object
    • summary