Empty / blank item in "select1" controls

We could not find in the xForms specifications an option that would allow "select1" controls to have (or not) an empty item in their lists.

I'm asking you this because sometimes users select a value in a "select1" by mistake and finally want to leave it blank. That's not possible if the list does not contain an empty item.

Any clue on this? Thanks for your advice.

Regards,

Guillaume

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I think I have the answer

I think I found the answer.

Check out this IBM wiki:
http://publib.boulder.ibm.com/infocenter/forms/v3r5m1/index.jsp?topic=/com.ibm.form.designer.xfdl.doc/i_xfdl_g_xforms_options_xforms_select1.html

Basically, the item set (determined by the xforms:item elements or the xforms:itemset element) may be empty if the bound nodes contain no data, or if the bound nodes are not relevant. In either case, the containing item is displayed without any choices. For example, a checkgroup would be displayed without any checks in it.

Hope this helps,

Lisa Caponigri

Empty item

The following form shows three methods of including an empty item in a xf:select1 control:

<html 
	xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:xf="http://www.w3.org/2002/xforms"
	xmlns:fp="urn:formsplayer.com"
>
	<head>
		<object id="formsPlayer" classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
			<strong>formsPlayer has not loaded. Please check your installation.</strong>
		</object>
		<?import namespace="xf" implementation="#formsPlayer" ?>
		
		<style type="text/css">
			xf\:label
			{
				width				: 200px;
			}
			
			xf\:output,
			xf\:select1
			{
				display				: block;
				margin-bottom		: 10px;
			}
			
			.highlight
			{
				font-weight			: bold;
				font-color			: orange;
			}
		</style>
		
		<xf:model id="mdl-x" functions="fp:HTMLSerialise">
			<xf:instance id="inst-options">
				<root xmlns="">
					<list id="list_empty_item">
						<opt label=""></opt>
					</list>
					<list id="list_a">
						<opt label=""></opt>
						<opt label="Option 1">First option value</opt>
						<opt label="Option 2">Second option value</opt>
						<opt label="Option 3">Third option value</opt>
					</list>
					<list id="list_b">
						<opt label="Apple">Apple value</opt>
						<opt label="Pear">Pear value</opt>
						<opt label="Orange">Orange value</opt>
					</list>
				</root>	
			</xf:instance>
			
			<xf:instance id="inst-choices">
				<root xmlns="">
					<one />
					<two />
					<three />
				</root>
			</xf:instance>
		</xf:model>
	</head>
	<body>
		<p>
			Show how xf:select1 controls can contain an empty value item.
		</p>
		<!-- 
			Tested with formsPlayer 1.6.1029.0, 1.7.1012.0
		-->
		
		<xf:select1 ref="instance('inst-choices')/one">
			<xf:label>Choose something (or nothing) <span class="highlight">xf:itemset</span></xf:label>
			<xf:itemset nodeset="instance('inst-options')/list[@id = 'list_a']/opt">
				<xf:label ref="@label" />
				<xf:value ref="." />
			</xf:itemset>
		</xf:select1>
		
		<xf:select1 ref="instance('inst-choices')/two">
			<xf:label>Choose something (or nothing) <span class="highlight">unioned xf:itemset</span></xf:label>
			<xf:itemset nodeset="(instance('inst-options')/list[@id = 'list_empty_item']/opt | instance('inst-options')/list[@id = 'list_b']/opt)">
				<xf:label ref="@label" />
				<xf:value ref="." />
			</xf:itemset>
		</xf:select1>
		
		<xf:select1 ref="instance('inst-choices')/three">
			<xf:label>Choose something (or nothing) <span class="highlight">xf:item</span></xf:label>
			<xf:item>
				<xf:label></xf:label>
				<xf:value></xf:value>
			</xf:item>
			<xf:item>
				<xf:label>Yes</xf:label>
				<xf:value>Yes</xf:value>
			</xf:item>
			<xf:item>
				<xf:label>No</xf:label>
				<xf:value>No</xf:value>
			</xf:item>
		</xf:select1>
		
		<xf:output value="fp:HTMLSerialise(instance('inst-options'))">
			<xf:label>inst-options</xf:label>
		</xf:output>
		
		<xf:output value="fp:HTMLSerialise(instance('inst-choices'))">
			<xf:label>inst-choices</xf:label>
		</xf:output>
	</body>
</html>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.