Opened 13 years ago

Closed 13 years ago

#8649 closed enhancement (fixed)

Added dojo.fieldToObject to xhr.js

Reported by: foobarfighter Owned by: James Burke
Priority: high Milestone: 1.4
Component: Core Version: 1.3.0b1
Keywords: Cc:
Blocked By: Blocking:


I needed to get the value of a single form field as opposed to all of the values of a form. In the case where I have a single ID and not the handle to the whole form, and I do not wish to retrieve all of the values of the form and then retrieve the field from the Object graph, it would be nice to have a utility method that handles all types of inputs.

Granted, you can get the handle to the form from the input field, but I don't think that works if the user did not include the input field within a form tag.

I added dojo.fieldToObject and refactored dojo.formToObject to use this method as well. Docs and tests are included in the patch. Let me know if this is something you want to add. I would consider this a post 1.3 patch.

The size difference is 669 bytes and I know dojo base is supposed to stay small, so there are a few options:

  1. Incorporate this into dojo base? I would assume there would need to be a conversation about it.
  2. Put dojo.fieldToObject somewhere else and keep dojo.formToObject the way it is
  3. Banish it from existence :)

My argument for this is that this might be a common use case for people that just want to check the value of a single field repeatedly in an RIA. Prototype currently supports this behavior with a Form.Element.Observer, and Rails supports this behavior with server side generated JS based on the Prototype library.

Attachments (1)

dojo.formToObject.refactor.patch (7.7 KB) - added by foobarfighter 13 years ago.

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by foobarfighter

comment:1 Changed 13 years ago by James Burke

Milestone: tbd1.4
Owner: changed from anonymous to James Burke

I apologize for not seeing this sooner -- I had some trouble getting notifications of new trac activity a while back, and apparently I missed this ticket. I'll set this for Dojo 1.4. Thanks for the contribution and particularly for including tests! Very cool!

comment:2 Changed 13 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [17469]) Fixes #9219, #8649, #7833 and #8724: allow publication of IO pipeline topics, add dojo.fieldToObject (thanks to foobarfighter, CLA on file), allow generic args.rawBody for setting HTTP request bodies, and if hasBody is not passed to dojo.xhr, make an intelligent guess as to whether the query should be in the http body or as a query string. \!strict for code has not side effects warning, but it is ok.

comment:3 Changed 13 years ago by Juho Manninen

Resolution: fixed
Status: closedreopened

Breaks radio button and checkbox groups - see #9420.

comment:4 Changed 13 years ago by James Burke

Resolution: fixed
Status: reopenedclosed

(In [18030]) Fixes #9420, #8649, treat single value radio or checkboxes as just a string. Thanks to Maine (CLA) for testcases and the fix.

Note: See TracTickets for help on using tickets.