error count is wrong when group becomes irrelevant

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

error count is wrong when group becomes irrelevant

sandraokeeffe
Hi,

I'm facing an issue where the error count is wrong for a particular group when that group becomes irrelevant.

What I have is a dropdown and depending on what value is selected, I may or maybe not have additional info. fields.  The additional fields are rendered by having a group corresponding to each dropdown that is relevant depending on the dropdown choice.  These fields have a bind associated with them depending on a type attribute.

E.g.
<xforms:bind nodeset="main/action-type-info/*[@type = 'number-list']" type="xs:string" constraint="matches(., '^([0-9]+){1}([,]{1}[0-9]+)*$')" required="true()" />
               
My problem is that the error-summary model still holds the errors for the additional info. fields even when that group becomes irrelevant.  I feel like there's something missing in my understanding of how the error-summary gets updated.

Any help would be much appreciated.

Here is the code snippet:

<div>

	<xforms:select1 id="my-input" ref="$instance/main/action-type"
		appearance="minimal">
		<xforms:label class="rivetlogic-xforms-label"
			ref="$resources/asset/main/action-type/label" />
		<xforms:itemset nodeset="xxforms:instance('action-types')/action-type">
			<xforms:label
				ref="$resources/asset/main/action-type/dropdown-labels/*[name() = context()/@label-id]" />
			<xforms:value ref="@value" />
		</xforms:itemset>
		<xforms:alert ref="$resources/asset/main/action-type/alert" />
		<xforms:hint clref="$resources/asset/main/action-type/hint" />

		<!-- when the action type changes, delete the existing additional info 
			(before adding the appropriate elements for the selected action type) -->
		<xforms:action ev:event="xforms-value-changed">
			<xforms:delete nodeset="$instance/main/action-type-info/*" />

		</xforms:action>

		<!-- add the additional info. elements to the descriptor instance for this 
			dropdown option (note: the num-fields attribute value must match the number 
			of field elements) -->
		<xforms:action ev:event="xforms-value-changed"
			while="(string(number(xxforms:instance('action-types')/*[@value = $instance/main/action-type]/@num-fields)) != 'NaN') and count($instance/main/action-type-info/*) lt (xxforms:instance('action-types')/*[@value = $instance/main/action-type]/@num-fields cast as xs:integer )">

			<xforms:insert
				origin="xxforms:element(xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=string(count($instance/main/action-type-info/*)+1)]/element-name, xxforms:attribute('type', xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=string(count($instance/main/action-type-info/*)+1)]/type))"
				context="$instance/main/action-type-info" nodeset="*" />
		</xforms:action>


	</xforms:select1>

</div>

<!-- action type info fields -->
<xforms:repeat nodeset="xxforms:instance('action-types')/action-type">


	<!-- create group for each action type, it is relevant when it is chosen 
		in the dropdown -->
	<xforms:group
		ref=".[count($instance/main/action-type[text() = context()/@value]) > 0]">

		<!-- number of additional info fields for this action type -->
		<xxforms:variable name="num-fields"
			select="context()/@num-fields cast as xs:integer" />

		<!-- add the additional info. input fields to the form for this dropdown 
			option (note: the num-fields attribute value must match the number of field 
			elements) -->
		<xforms:repeat nodeset="(1 to $num-fields)">
			<xxforms:variable name="i" select="." />
			<div >
				<xforms:input
					ref="$instance/main/action-type-info/*[name() = (xxforms:instance('action-types')/*[@value= $instance/main/action-type]/field[@id=$i]/element-name)]"
					incremental="false"
					xxforms:maxlength="{xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=$i]/maxlength}">
					<xforms:label class="rivetlogic-xforms-label"
						ref="$resources/asset/main/action-type/additional-info-fields/*[name() = (xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=$i]/element-name)]/label" />
					<xforms:alert
						ref="$resources/asset/main/action-type/additional-info-fields/*[name() = (xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=string($i)]/element-name)]/alert" />
					<xforms:hint
						ref="$resources/asset/main/action-type/additional-info-fields/*[name() = (xxforms:instance('action-types')/*[@value = $instance/main/action-type]/field[@id=string($i)]/element-name)]/hint" />
				</xforms:input>
			</div>
		</xforms:repeat>

	</xforms:group>

</xforms:repeat>

Thanks in advance,
Sandra
Reply | Threaded
Open this post in threaded view
|

Re: error count is wrong when group becomes irrelevant

sandraokeeffe
Just to follow up, I was pointed to this http://stackoverflow.com/questions/4370859/error-summary-component-with-repeat, where it looks like someone else faced the same issue.

I'm currently on 3.8.0 CE, but tested on the latest, 3.9.0 RC1 CE, and it fixed the problem.

Thanks,
Sandra