define [ "dijit/_Container", "dijit/form/_FormMixin", "dijit/registry", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/event", "dojo/on" ], (_Container, _FormMixin, registry, array, declare, event, _on) -> declare [_Container,_FormMixin], name: "" value: null disabled: false readOnly: false postCreate: () -> @inherited arguments if @domNode.tagName.toLowerCase() isnt "form" 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
as the root element in your template for", @declaredClass @own ( _on @domNode, 'submit', (evt) => @_handleSubmit evt ) _setDisabledAttr: (value) -> @_set "disabled", value array.forEach @_getDescendantFormWidgets(), (child) => child.set "disabled", value _setReadOnlyAttr: (value) -> @_set "readOnly", value array.forEach @_getDescendantFormWidgets(), (child) => child.set "readOnly", value focus: () -> children = @_getDescendantFormWidgets() children[0].focus() if children.length > 0 _handleSubmit: (evt) -> node = @domNode until not node or ( widget and typeof widget._onSubmit is "function" ) node = node.parentNode widget = registry.byNode node if node widget._onSubmit(evt) if widget # we always stop the event, since this is a widget after all event.stop evt if evt false