chris
chris

Reputation: 47

form builder repeat index

I recently created a Form Builder form with a repeat to show a list of data. The repeat is working fine. My question is that i need to get the index for the data inside the repeat so that i can use it to get another set of data from tables.

Here is my

<fr:grid columns="2" repeat="true" ref="instance('fr-form-data')/name" id="data-repeat" origin="instance('fr-form-data-template')">
    <xh:tr>
        <xh:td>
            <xf:output id="name-control" ref="person_name">
                <xf:label>Name :</xf:label>
            </xf:output>
        </xh:td>
        <xh:td>
            <xf:trigger>
                <xf:label>Get</xf:label>
                <xf:action ev:event="DOMActivate">
                    <xf:setvalue ref="instance('fr-param-instance')/person/mni" value="am_mni"/>
                    <xf:send submission="get-invl"/>
                </xf:action>
            </xf:trigger>
        </xh:td>
    </xh:tr>
</fr:grid>  

I need to get the data to put inside here:

<xf:setvalue ref="instance('fr-param-instance')/person/mni" value="am_mni"/>

Thanks

Upvotes: 0

Views: 330

Answers (1)

avernet
avernet

Reputation: 31743

If you have an element am_mni inside the repeat, at the same level of person_name, then your xf:setvalue can look like:

<xf:setvalue ref="instance('fr-param-instance')/person/mni"
             value="context()/am_mni"/>

context() refers to the context in which the xf:setvalue runs, which will be the current repeat iteration, since it is inside a repeat. If you just write value="am_mni", this will be evaluated relative to the ref, and thus return instance('fr-param-instance')/person/mni/am_mni, which in your case is most likely an empty sequence.

Upvotes: 1

Related Questions