Login Register

Ideas for enhancements to form widgets

After discussion with nonken on IRC this morning, I decided to write another forum post suggesting some direction for new form widget development. This grew out of a discussion of support for ranges and date/time pickers as form widgets.

During the discussion, it was found that in many cases, there are situations where one would want to "combine" form widgets together into a "single" widget. An example of this is the password widget found in dojox.form.PasswordValidator. Other examples would be a widget that returns *BOTH* the date and time in a single JS object, or a widget that allows for specifying a date range. Rather than creating new widgets in these cases, it would be helpful to have a single widget which knows how to do things like "validate()", "getValue()", "setValue()", etc on it's original widgets. It can correspond to a native widget with type="hidden".

I would like to suggest we create a dijit.form._CombinedFormWidget widget - which will handle some of the common actions in such a setup - such as passing disabled, required, etc down to the "original" widgets, and connecting the appropriate validate, getValue, setValue, onChange functions. Other widgets (such as the PasswordValidator, range, and date/time widgets) could extend this and implement their own handling of those functions.

The main strength behind this approach is the ability to keep our current API for form widgets, and add to it the ability to combine individual values into a single one (as well as provide enhanced validation, etc). It also shouldn't affect any a11y stuff - since each individual widget would still have its own a11y.

The next step we discussed was creating a dijit.form.DateTimeTools namespace (or some other name) - which can be used to house certain "combined" widgets - such as range, date/time, etc.

I would like to have a discussion (on this forum), as well as possibly in our next dijit meeting to get thoughts and ideas about this approach.