Opened 14 years ago
Closed 5 years ago
#4694 closed enhancement (patchwelcome)
Form: add support for isDirty()
Reported by: | gizmojo.org | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.13 |
Component: | Dijit - Form | Version: | 0.9 |
Keywords: | Form | Cc: | |
Blocked By: | Blocking: |
Description (last modified by )
Give Form an isDirty() method, similar to the isDirty method provided by datastore. Such a method could be used to determine whether to enable/disable buttons, or maybe to dynamically change the label on buttons, or to prompt user whether to discard any changes, etc.
Such a functionality should be accompanied by the possibility to reset the form (and not necessarily to the values the form was originally loaded with).
A simple take on this could be to give each form widget an own isDirty() method, and then add a Form.isDirty() that just loops over those. However, this is limited to scenarios where each form field is also a dojo widget.
Another more generic take, can be based on the dom element's default values, i.e. since form was "loaded" (not, unfortunately, since form was last "undirtied", e.g. re-instantiated with the values of another "item"). Some sample code for this variation is at: http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-development-discussion/form-isdirty
A 3rd and maybe better approach, is to make the Form widget remember reference values for contained fields (whether dojo widgets or not) that an isDirty() method could check field values against. An unDirty() method should also be provided to reset the fields to these reference values (that may be different than the standard reset() method, that resets to default values when Form was loaded). Re-instantiating the form with the values of another "item" would therefore also reset the form's reference values.
See also: #4692
Change History (8)
comment:1 Changed 13 years ago by
Milestone: | 1.1 → 1.2 |
---|
comment:2 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.2 → 1.3 |
comment:3 Changed 13 years ago by
Summary: | Add support for Form.isDirty() → Form: add support for isDirty() |
---|
comment:4 Changed 12 years ago by
Milestone: | 1.3 → 1.4 |
---|
bumping 1.4 tickets to 1.5, and most 1.3 tickets to 1.4
comment:5 Changed 12 years ago by
Milestone: | 1.4 → 1.5 |
---|
comment:6 Changed 11 years ago by
Milestone: | 1.5 → future |
---|
comment:7 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
comment:8 Changed 5 years ago by
Milestone: | future → 1.12 |
---|---|
Resolution: | → patchwelcome |
Status: | new → closed |
Given that no one has shown interest in creating a patch in the past 7 years, I'm closing this as patchwelcome. I think most of what is needed here can be handled by form.get/set using dijit/form/Form.
We'd also need notification whenever a value changes (similar to onValidStateChange()).