Re: forms-lite and data models

On Thu, 26 Oct 2006, John Boyer wrote:

> 3) A third problem with the variable approach is that it breaks at 
> the first sight of a grouping. Suppose for example that you create 
> an "address block"
>
> <group name="address">
>  <label>Ship to:</label>
>  <input name="name" ...
>  <input name="street" ...
>  <input name="city" ...
>  <input name="region" ...
>  <input name="country" ...
>  <input name="postalcode" ...
> </group>
>
> Nice. Now you want it again because you need a "Bill to" address:
>
> <group name="billto">
>  <label>Bill to:</label>
>  <input name="name" ...
>  <input name="street" ...
>  <input name="city" ...
>  <input name="region" ...
>  <input name="country" ...
>  <input name="postalcode" ...
> </group>

For currently deployed web browsers the above means that form.street 
etc. is an array of two items. This is because the existing HTML 
forms object model uses a flat namespace for the fields belonging to 
a given form. If you know the missing structure, you can restore it 
from the data submitted to the server. The alternative is to use 
different names, e.g. with a prefix that distinguishes the fields 
from the shipping and billing addresses. This then requires a model 
the describes the relationship between these names and the 
structured data model. Such a model can be a little verbose.

By the way, in the spirit of only making incremental changes to 
HTML, I would suggest the use of the existing HTML fieldset and
legend elements in place of group and label above. This had the
further advantage that existing browsers provide a nice rendering
and understand the relationship between a fieldset and its caption
(as given by the legend element).

The billing/shipping address example is interesting in that it 
doesn't really show the need for structured references. You can
still indicate which fields are required, and you can define
expressions as to whether the shipping address needs to be filled
out via an attribute on the fieldset element. The forms-lite testbed 
supports the relevant attribute on fieldset elements for that 
purpose.

  Dave Raggett <dsr@w3.org> http://www.w3.org/People/Raggett

Received on Thursday, 26 October 2006 18:08:18 UTC