Opened 11 years ago

Closed 9 years ago

#6924 closed enhancement (wontfix)

Form and form widgets: please provide method(s) to get/set serialized values

Reported by: yatessc@… Owned by:
Priority: high Milestone: 1.6
Component: Dijit Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:

Description

For more complex form widgets like DateTextBox/TimeTextBox where the value is a Javascript object (in those cases a Date object), the widget's get/setValue methods return/accept object values, and thus Form.get/setValues also return/expect object values within the values structure. There are circumstances in which it would be useful to get/set the values in a serializable format, such as JSON (see this discussion on the Dijit Development Forum).

I would like to request the addition of get/setSerializedValues methods (or perhaps just serialize/deserialize) to dijit.Form. The getSerializedValues method could perhaps just call the widget's serialize() method if exists, getValue otherwise, and return a JSON formatted string representing the values of the form widgets, while the setSerializedValues method should set the values of the widgets based on an equivalent JSON string. This would presumably require the addition of a corresponding deserialize() method to those widgets that have a serialize method. Obviously, Checkbox type widgets would require similar special handling as in get/setValues to generate/use an array of values.

Change History (5)

comment:1 Changed 11 years ago by bill

Cc: yatessc@… removed
Milestone: 1.3
Reporter: changed from guest to yatessc@…

BTW I thought about this some, and considered calling getDisplayedValue()/setDisplayedValue(), but thinking again that doesn't seem like a good idea because of localization issues (ie, if you serialized a form and then sent the data to the server, the dates wouldn't necessarily be in the format expected).

comment:2 Changed 11 years ago by bill

Milestone: 1.31.4

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

comment:3 Changed 10 years ago by bill

Milestone: 1.41.5

comment:4 Changed 9 years ago by Adam Peller

Milestone: 1.51.6

comment:5 Changed 9 years ago by bill

Resolution: wontfix
Status: newclosed

Sorry I never got to this. For 2.0 I'm going to change DateTextBox and TimeTextBox's values to be strings, rather than Date objects. I don't know any other widgets that return objects besides dijit.form.Form itself, so I don't see a compelling reason to add a serializedValue attribute (or get("serializedValue") support) to each widget.

In the meantime I think you could write a DateTextBox._getValueAttr() method that returns a String instead of a Date, and then dijit.form.Form would use that for it's value.

Note: See TracTickets for help on using tickets.