diff gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl @ 414:59c6c7b62e43

Automatically select entry in multi select boxes if there is only one entry to avoid input failures. gnv/trunk@636 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 27 Jan 2010 13:26:02 +0000
parents 0ce07c6e132c
children 60caaa265e2b
line wrap: on
line diff
--- a/gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl	Mon Jan 25 14:53:38 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl	Wed Jan 27 13:26:02 2010 +0000
@@ -26,6 +26,11 @@
 
         <legend><xsl:value-of select="xform:label"/></legend>
         <xsl:choose>
+            <xsl:when test="$items = 1">
+                <select name="{$selectName}" multiple="multiple" size="{$items}">
+                    <xsl:apply-templates mode="selected"/>
+                </select>
+            </xsl:when>
             <xsl:when test="$items &lt; 5">
                 <select name="{$selectName}" multiple="multiple" size="{$items}">
                     <xsl:apply-templates/>
@@ -58,6 +63,15 @@
     </xsl:template>
 
 
+    <xsl:template match="xform:item" mode="selected">
+        <xsl:variable name="optionValue" select="xform:value"/>
+            <option value="{$optionValue}" selected="selected">
+                <xsl:value-of select="xform:label"/>
+            </option>
+    </xsl:template>
+
+
+
     <xsl:template match="xform:group">
         <legend>
             <xsl:value-of select="xform:label"/>

http://dive4elements.wald.intevation.org