1 | define([ |
---|
2 | "dijit/_Container", |
---|
3 | "dijit/form/_FormMixin", |
---|
4 | "dojo/_base/array", |
---|
5 | "dojo/_base/declare", |
---|
6 | "dojo/_base/event" |
---|
7 | ], function(_Container, _FormMixin, array, declare, event) { |
---|
8 | return declare([_Container,_FormMixin],{ |
---|
9 | name: "", |
---|
10 | value: null, |
---|
11 | disabled: false, |
---|
12 | readOnly: false, |
---|
13 | postCreate: function() { |
---|
14 | this.inherited(arguments); |
---|
15 | if ( this.domNode.tagName.toLowerCase() !== "form" ) { |
---|
16 | console.warn("Not scoping a _ComplexValueMixin in a form element can cause name clashes. E.g. radio buttons might stop working correctly. It is recommended to use <form> as the root element in your template for "+this.declaredClass+"."); |
---|
17 | } |
---|
18 | }, |
---|
19 | _setDisabledAttr: function(value) { |
---|
20 | this._set("disabled", value); |
---|
21 | array.forEach(this._getDescendantFormWidgets(), function(child){ |
---|
22 | child.set("disabled", value); |
---|
23 | }); |
---|
24 | }, |
---|
25 | _setReadOnlyAttr: function(value) { |
---|
26 | this._set("readOnly", value); |
---|
27 | array.forEach(this._getDescendantFormWidgets(), function(child){ |
---|
28 | child.set("readOnly", value); |
---|
29 | }); |
---|
30 | }, |
---|
31 | focus: function() { |
---|
32 | var children = this._getDescendantFormWidgets(); |
---|
33 | if ( children.length > 0 ) { |
---|
34 | children[0].focus(); |
---|
35 | } |
---|
36 | }, |
---|
37 | onSubmit: function(e) { |
---|
38 | // since this widget is used to create more complex |
---|
39 | // widgets within other forms, the onSubmit must either be |
---|
40 | // ignored or propagated, but not handled here. |
---|
41 | if ( e ) { event.stop(e); } |
---|
42 | return false; |
---|
43 | }, |
---|
44 | _onSubmit: function(e) { |
---|
45 | // since this widget is used to create more complex |
---|
46 | // widgets within other forms, the onSubmit must either be |
---|
47 | // ignored or propagated, but not handled here. |
---|
48 | if ( e ) { event.stop(e); } |
---|
49 | return false; |
---|
50 | } |
---|
51 | }); |
---|
52 | }); |
---|