Question about set value of multiple nodes

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

Question about set value of multiple nodes

pumbosha
Hi,

I have the following question:

I have form:

<form>
    <section-1>
        <control-1/>
        <grid-3>
             <tekst1/>
         </grid-3>
         <grid-3>
             <tekst1/>
         </grid-3>
         <grid-3>
            <tekst1/>
         </grid-3>
    </section-1>
</form>

and instance:

<instance id="myInstance">
   <vars>
      <var>A</var>
      <var>B</var>
      <var>C</var>
   </vars>
</instance>

and I want to fill form with data from instance:

<form>
    <section-1>
        <control-1/>
        <grid-3>
             <tekst1>A</tekst1>
         </grid-3>
         <grid-3>
             <tekst1>B</tekst1>
         </grid-3>
         <grid-3>
            <tekst1>C</tekst1>
         </grid-3>
    </section-1>
</form>

How can I reach this? Is it possible to use setvalue:

<xf:var as="xs:string" name="control-value" select="instance('myInstance')/vars/var"/> 

<xf:setvalue ref="form/section-1/grid-3/tekst1" value="$control-value"/> 

?
Reply | Threaded
Open this post in threaded view
|

Re: Question about set value of multiple nodes

Erik Bruchez
Administrator
Here is a working example:

    https://gist.github.com/ebruchez/a0f2113be610b97c582d

I hope this helps,

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Question about set value of multiple nodes

pumbosha
Hey, I'm most grateful to you! This solution will be very helpful for me.

regards
Reply | Threaded
Open this post in threaded view
|

Re: Question about set value of multiple nodes

Erik Bruchez
Administrator
Glad it helped :) -Erik