Skip to content

Commit

Permalink
Form, _FormMixin: remove deprecated API's
Browse files Browse the repository at this point in the history
- Form: remove execute(), onExecute() (should use onSubmit() instead)
- _FormMixin: remove setValues(), getValues(), isValid(), onValidStateChange(), disconnectChildren()
- extend _WidgetBase not _Widget
  • Loading branch information
wkeese committed May 10, 2013
1 parent ad34276 commit 76210d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 65 deletions.
37 changes: 5 additions & 32 deletions form/Form.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
define([
"dojo/_base/declare", // declare
"dojo/dom-attr", // domAttr.set
"dojo/_base/kernel", // kernel.deprecated
"dojo/sniff", // has("ie")
"../_Widget",
"../_WidgetBase",
"../_TemplatedMixin",
"./_FormMixin",
"../layout/_ContentPaneResizeMixin"
], function(declare, domAttr, kernel, has, _Widget, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin){
], function(declare, domAttr, has, _WidgetBase, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin){

// module:
// dijit/form/Form


return declare("dijit.form.Form", [_Widget, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin], {
return declare("dijit.form.Form", [_WidgetBase, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin], {
// summary:
// Widget corresponding to HTML form tag, for validation and serialization
//
Expand Down Expand Up @@ -56,28 +55,7 @@ define([
// Target frame for the document to be opened in.
target: "",

templateString: "<form data-dojo-attach-point='containerNode' data-dojo-attach-event='onreset:_onReset,onsubmit:_onSubmit' ${!nameAttrSetting}></form>",

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 _setNameAttr 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
},
templateString: "<form data-dojo-attach-point='containerNode' data-dojo-attach-event='onreset:_onReset,onsubmit:_onSubmit'></form>",

_setEncTypeAttr: function(/*String*/ value){
domAttr.set(this.domNode, "encType", value);
Expand Down Expand Up @@ -129,12 +107,7 @@ define([

_onSubmit: function(e){
var fp = this.constructor.prototype;
// TODO: remove this if statement beginning with 2.0
if(this.execute != fp.execute || this.onExecute != fp.onExecute){
kernel.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
e.stopPropagation();
e.preventDefault();
Expand Down
35 changes: 2 additions & 33 deletions form/_FormMixin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
define([
"dojo/_base/array", // array.every array.filter array.forEach array.indexOf array.map
"dojo/_base/declare", // declare
"dojo/_base/kernel", // kernel.deprecated
"dojo/_base/lang", // lang.hitch lang.isArray
"dojo/on",
"dojo/window" // winUtils.scrollIntoView
], function(array, declare, kernel, lang, on, winUtils){
], function(array, declare, lang, on, winUtils){

// module:
// dijit/form/_FormMixin
Expand Down Expand Up @@ -71,7 +70,7 @@ define([

validate: function(){
// summary:
// returns if the form is valid - same as isValid - but
// returns if the form is valid and
// provides a few additional (ui-specific) features:
//
// 1. it will highlight any sub-widgets that are not valid
Expand All @@ -92,10 +91,6 @@ define([
}), function(item){ return item; });
},

setValues: function(val){
kernel.deprecated(this.declaredClass+"::setValues() is deprecated. Use set('value', val) instead.", "", "2.0");
return this.set('value', val);
},
_setValueAttr: function(/*Object*/ obj){
// summary:
// Fill in form values from according to an Object (in the format returned by get('value'))
Expand Down Expand Up @@ -211,10 +206,6 @@ define([
// which I am monitoring.
},

getValues: function(){
kernel.deprecated(this.declaredClass+"::getValues() is deprecated. Use get('value') instead.", "", "2.0");
return this.get('value');
},
_getValueAttr: function(){
// summary:
// Returns Object representing form values. See description of `value` for details.
Expand Down Expand Up @@ -339,23 +330,6 @@ define([
return obj;
},

isValid: function(){
// summary:
// Returns true if all of the widgets are valid.
// Deprecated, will be removed in 2.0. Use get("state") instead.

return this.state == "";
},

onValidStateChange: function(/*Boolean*/ /*===== isValid =====*/){
// summary:
// Stub function to connect to if you want to do something
// (like disable/enable a submit button) when the valid
// state changes on the form as a whole.
//
// Deprecated. Will be removed in 2.0. Use watch("state", ...) instead.
},

_getState: function(){
// summary:
// Compute what this.state should be based on state of children
Expand All @@ -367,11 +341,6 @@ define([
array.indexOf(states, "Incomplete") >= 0 ? "Incomplete" : "";
},

disconnectChildren: function(){
// summary:
// Deprecated method. Applications no longer need to call this. Remove for 2.0.
},

connectChildren: function(/*Boolean*/ inStartup){
// summary:
// You can call this function directly, ex. in the event that you
Expand Down

0 comments on commit 76210d1

Please sign in to comment.