dimanche 8 février 2015

Adding checkbox to XForms repeat structure

I'm using XSLTForms in eXist 2.2 with the RESTXQ server.


I have a search form that lets users query a remote API, which responds with a set of XML records if the query is matched. I am using xf:repeat to iterate over the records, and I want to be able to provide a checkbox at the head of each record, so that the user can choose the records they want. However, when I place a checkbox element inside xf:repeat (using xf:input bound to a boolean value), I don't get the desired functionality. Instead of being independent of each other, the checkboxes get activated as a group. When I click the first box, the second box is activated as well, etc. This seems as though it would be a common enough use case, but I can't seem to find any documentation about how to implement it.


Model snippet:



<xf:instance xmlns="" id="default">
<results>
<sru:searchRetrieveResponse>
<sru:records>
<sru:record>
...
</sru:record>
</sru:records>
</sru:searchRetrieveResponse>
<sru:searchRetrieveResponse>
<sru:records>
<sru:record>
...
</sru:record>
</sru:records>
</sru:searchRetrieveResponse>
</results>
</xf:instance>

<xf:instance xmlns="" id="test">
<data>
<bool>false</off>
</data>
</xf:instance>

<xf:bind nodeset="instance('test')/bool" id="boolVal" type="xs:boolean"/>


Form snippet with xf:repeat:



<div>
<xf:repeat
nodeset="instance('default')/sru:searchRetrieveResponse/sru:records/sru:record"
id="marc-repeat" appearance="full">
<div class="checkbox">
<xf:input incremental="true" ref="instance('test')/bool">
<xf:label>Select</xf:label>
</xf:input>
</div>
...
</xf:repeat>
</div>




Aucun commentaire:

Enregistrer un commentaire