Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.1.11
-
None
-
None
-
Patch available
Description
I have a form with a multivaluefield displayed as checkboxes. When one of the checkboxes is checked or unchecked, I need the fd:on-value-changed script to be executed. I believe this should happen when the submit-on-change attribute is added to the fi:styling element in the template.
I added the following line in forms-field-styling.xsl to solve the problem.
<!--+
| fi:multivaluefield : produce a list of checkboxes
+-->
<xsl:template match="fi:multivaluefield[fi:styling/@list-type='checkbox']">
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
<xsl:variable name="state" select="@state" />
<span id="{@id}" title="{fi:hint}">
<xsl:for-each select="fi:selection-list/fi:item">
<xsl:variable name="value" select="@value"/>
<xsl:variable name="item-id" select="concat($id, ':', position())"/>
<input id="{$item-id}" type="checkbox" value="{@value}" name="{$id}">
<xsl:apply-templates select="." mode="css"/>
<!-- added -->
<xsl:apply-templates select="../.." mode="styling"/>
<xsl:if test="$state = 'disabled'">
<xsl:attribute name="disabled">disabled</xsl:attribute>
</xsl:if>
<xsl:if test="$values[. = $value]">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
<xsl:apply-templates select="." mode="label">
<xsl:with-param name="id" select="$item-id"/>
</xsl:apply-templates>
<br/>
</xsl:for-each>
<xsl:apply-templates select="." mode="common"/>
</span>
</xsl:template>
I added the following line in forms-field-styling.xsl to solve the problem.
<!--+
| fi:multivaluefield : produce a list of checkboxes
+-->
<xsl:template match="fi:multivaluefield[fi:styling/@list-type='checkbox']">
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="fi:values/fi:value/text()"/>
<xsl:variable name="state" select="@state" />
<span id="{@id}" title="{fi:hint}">
<xsl:for-each select="fi:selection-list/fi:item">
<xsl:variable name="value" select="@value"/>
<xsl:variable name="item-id" select="concat($id, ':', position())"/>
<input id="{$item-id}" type="checkbox" value="{@value}" name="{$id}">
<xsl:apply-templates select="." mode="css"/>
<!-- added -->
<xsl:apply-templates select="../.." mode="styling"/>
<xsl:if test="$state = 'disabled'">
<xsl:attribute name="disabled">disabled</xsl:attribute>
</xsl:if>
<xsl:if test="$values[. = $value]">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
<xsl:apply-templates select="." mode="label">
<xsl:with-param name="id" select="$item-id"/>
</xsl:apply-templates>
<br/>
</xsl:for-each>
<xsl:apply-templates select="." mode="common"/>
</span>
</xsl:template>