Request for FormData.remove() method

Hi,

I must admit I am ignorant of the W3C process for drafting the 
XMLHttpRequest, but I see that the webpage says to send feedback to this 
address, so I am writing this email to submit my feedback.

The "new FormData(form)" constructor is an especially handy way to slurp 
in all the data for a given form.  As the documentation describes, the 
algorithm for constructing the form data set is quite intricate -- it 
takes 3 pages to describe.

I have an application where I need to change or remove field values that 
were received from the user, before they are submitted using an XHR.  
(I'm removing cue text from text input fields.)  It would be ideal to 
call some sort of FormData.remove() (or perhaps "removeAllByName") 
method.  Unfortunately, no function like that is defined in the FormData 
interface.  The most obvious alternative is to re-implement the 3-page 
algorithm to construct the form data set, and then add my 
application-specific twist.  That's not a simple task to get perfect.

I can think of a few workarounds, but none are great.  I could change 
the field values before constructing FormData, but that would be visible 
to the user, and I would need to revert the field values if the user 
needs to continue interacting with the form (e.g. to fix an error 
reported by the server).  A slightly better workaround would be to 
change or remove the field names before constructing FormData, because 
that would not be visible to the user.  However, it would still require 
un-doing and still feels like a hack.

In contrast, adding additional fields to FormData after construction is 
simple; just call FormData.append().

Here's my proposal for a FormData.removeAllByName() method:

    fd.removeAllByName(name)

      * Removes all name/value pairs matching the specified name.
      * Returns a number indicating how many name/value pairs were removed.

Thank you,
David

Received on Wednesday, 18 April 2012 12:04:04 UTC