I'd like to ask the user via an xf:input, "how many items" do you want in a certain repeat, and then, based on the user's response, present a repeat with that number of rows (which I guess would also be generated in the xf:instance).
I'm familiar with using triggers to insert and delete rows.
What I'm asking here is how to prompt the user for the initial number of rows to be created and presented.
For example, suppose the user wanted 10 rows. I guess the repeated data could be made not relevant, until they'd answered that question, and when they answer it, some action could dynamically create the rows, and then make the repeated data relevant.
But how to do this?
Update 20 Dec
The markup below presents an input field, and in betterform, does add rows to the instance when the button is pressed. However, betterForm doesn't display the data in the UI (though I guess this is strictly a separate question). I haven't tried other implementations.
<xhtml:head>
<xf:model id="m">
<xf:instance id="main-instance">
<data>
<items>
<item1>item 11</item1>
<item2>item 12</item2>
<item3>item 13</item3>
</items>
</data>
</xf:instance>
<xf:instance id="variable">
<variable xmlns="">
<iteration-count/>
</variable>
</xf:instance>
</xf:model>
</xhtml:head>
<xhtml:body>
<!-- Simple field to enter the number of iterations -->
<xf:input ref="instance('variable')/iteration-count">
<xf:label>How many iterations?</xf:label>
</xf:input>
<xf:trigger>
<xf:label>Insert with while</xf:label>
<xf:action ev:event="DOMActivate">
<xf:action while="instance('variable')/iteration-count != 0">
<xf:insert ev:event="DOMActivate" nodeset="items"/>
<xf:setvalue ref="instance('variable')/iteration-count" value=". - 1"/>
</xf:action>
<!--<xf:refresh model="m"/>-->
</xf:action>
</xf:trigger>
<table>
<tbody id="r-attrs" xf:repeat-nodeset="items">
<tr>
<td>
<xf:output ref="item1"></xf:output>
</td>
<td>
<xf:output ref="item2"></xf:output>
</td>
<td>
<xf:output ref="item3"></xf:output>
</td>
</tr>
</tbody>
</table>
</xhtml:body>
The while and the iterate attributes of an action will repeat this action.