W3C home > Mailing lists > Public > www-forms@w3.org > July 2008

Re: Question about form design with optional elements

From: Ulrich Nicolas Lissť <unl@dreamlab.net>
Date: Thu, 17 Jul 2008 10:41:00 +0200
Message-ID: <487F059C.7030608@dreamlab.net>
To: Swithun Crowe <swithun@swithun.servebeer.com>
CC: "Clark, John" <CLARKJ2@ccf.org>, www-forms@w3.org


this is only part of the trick, because when the relevant MIP is false, 
"associated form controls (and any children) and group and switch 
elements (including content) must be made unavailable, removed from the 
navigation order, and not allowed focus. Typically, non-relevant content 
is not presented, or it may be styled as disabled." [1]

Setting all empty fields to non-relevant would make them unavailable for 
editing. However, if you use a controller instance keeping the editing 
state, you can use this trick:

<xf:instance id="controller" xmlns="">

Then you can use binding expression like:

<xf:bind nodeset="instance('maximal-base')/*" 
relevant="instance('controller')/state='submit' .!=''"/>

So all fields are relevant when the state is not 'submit'. Last part of 
the trick is using event handlers for the xforms-submit* events to set 
the state:

<xf:submission ...>
     <xf:setvalue ref="instance('controller')/state" 
     <xf:setvalue ref="instance('controller')/state" 
     <xf:setvalue ref="instance('controller')/state" 


[1] http://www.w3.org/TR/xforms/#model-prop-relevant

Swithun Crowe wrote:
> Hello
> CJ Another approach is to start with a maximal base instance,
> CJ 
> CJ   <xf:instance id="maximal-base">
> CJ     <X>
> CJ       <a/>
> CJ       <b/>
> CJ       <c/>
> CJ     </X>
> CJ   </xf:instance>
> CJ 
> CJ and then remove any of the optional elements that are "empty" when the 
> CJ instance is submitted.  This approach requires expanding the starting 
> CJ state of the instance data to its maximal form before editing, and then 
> CJ pruning it back again after editing.  Our experiments have performed 
> CJ both expanding and pruning on the server side, although it may be 
> CJ possible to do these operations using XForms itself.  For example, 
> CJ pruning could be implemented using some creative "relevance" MIPs.  
> This is what relevance is for. It needn't be very creative. Something 
> like:
> <xf:bind nodeset="instance('maximal-base')/*" relevant=".!=''"/>
> would do it. You might need to use CSS to ensure that elements are still 
> visible and editable while they are empty. But relevance will remove the 
> empties before the instance is submitted.
> Swithun.

Ulrich Nicolas Lissť
Received on Thursday, 17 July 2008 08:41:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:21 UTC