[whatwg] Web Forms 2.0: Repeating blocks and move-up/move-down

I've been implementing a form repetition Javascript library, basing it
on the Web Forms spec as closely as I can.  But during that I've become
confused about the purpose of move-up and move-down, as well as other
things to define order (like having an add button inside a repetition
block).

Because these don't effect the index in any way (that I can see) and so
don't effect the names of any fields inside the repetition block, how is
the server supposed to make any use of the order?  I suppose the order
of the fields as submitted would indicate that, but few web programming
frameworks give easy access to that ordering, especially for POST
variables.  Even though it seems more complicated to implement, changing
the repetition index would make the reordering functionality much more
useful.

Considering it from an implementation perspective, I'd guess that when
creating a repetition block I'd track which attributes needed rewriting.
  Then when changing the index (as would happen when reordering) I'd
re-rewrite those attributes.  E.g., I'd add a templateAttributes
property to any DOM node where I rewrote attributes when creating a
block, which would be a list of the original (unmodified) attributes.

This could probably be a specified method of repetition blocks, perhaps
a .changeRepetitionIndex(index) method.  .moveRepetitionBlock(distance)
would result in two blocks swapping indexes (or multiple swaps, if
abs(distance)>1).  Somewhat more awkwardly,
.addRepetitionBlock(insertAfter) (when not appending) would potentially
have to change the index of all blocks that followed it (to make room
for the new block).  But even so, the result seems vastly more useful.

Tangentially, I wasn't clear how the template index was supposed to be
stored.  Is it a property of the template node?  Is it an attribute?

Also, there's no example of using <input> tags for add/remove buttons.
These are (sensibly) discouraged; but if they are used, are they
expected to be used like <input type="add" value="Add a Block"> ?  I.e.,
as another input type?

There's also no specific description of .addRepetitionBlockByIndex(), or
what its intended use is.

Lastly, it's occurred to me that a form like:

   <div repeat="template" id="foo">
     <input type="hidden" name="foo-order" value="[foo]">
     ...
   </div>

would be easier to handle, as you could reorder the (unordered) input
based on the foo-order values, as most frameworks do preserve the order
of values when multiple variables with the same name are submitted, even
if they don't preserve any order between differently named variables.
If this is the intention, then some suggestion along those lines in the
spec would be useful.

Thanks!

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org

Received on Thursday, 27 October 2005 08:40:37 UTC