Opened 14 years ago

Closed 6 years ago

#4694 closed enhancement (patchwelcome)

Form: add support for isDirty()

Reported by: Owned by: bill
Priority: high Milestone: 1.13
Component: Dijit - Form Version: 0.9
Keywords: Form Cc:
Blocked By: Blocking:

Description (last modified by bill)

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:

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 14 years ago by bill

Milestone: 1.11.2

comment:2 Changed 13 years ago by bill

Description: modified (diff)
Milestone: 1.21.3

comment:3 Changed 13 years ago by bill

Summary: Add support for Form.isDirty()Form: add support for isDirty()

We'd also need notification whenever a value changes (similar to onValidStateChange()).

comment:4 Changed 13 years ago by bill

Milestone: 1.31.4

bumping 1.4 tickets to 1.5, and most 1.3 tickets to 1.4

comment:5 Changed 12 years ago by bill

Milestone: 1.41.5

comment:6 Changed 12 years ago by bill

Milestone: 1.5future

comment:7 Changed 11 years ago by bill

Component: DijitDijit - Form

comment:8 Changed 6 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: newclosed

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.

Note: See TracTickets for help on using tickets.