Loading ...
Sorry, an error occurred while loading the content.

xforms:input in more than one instance

Expand Messages
  • ALessio & Raoul
    This may be a stupid question, but... does anybody knows how to take data from a single xforms:input and put it in more than one instance? We have tried to use
    Message 1 of 2 , Dec 4, 2003
    • 0 Attachment
      This may be a stupid question, but...
      does anybody knows how to take data from a single xforms:input and put it in more than one instance?
      We have tried to use the "|" in the ref="..." attribute of the xforms:input, but it doesn't work well...

      Example:

      ...
      <xforms:model id="MyModel">
      <xforms:instance>
      ...
      <BuyerContact/>
      ...
      </xforms:instance>
      <xforms:instance id="secondinstance">
      ...
      <BuyerContact/>
      ...
      </xforms:instance>
      ...
      ...
      </xforms:model>

      ...
      <body>
      ...
      <xforms:label>Buyer Contact:</xforms:label>
      <xforms:input ref="BuyerContact|instance('secondinstance')/BuyerContact">
      ...
      </body>


      The "secondinstance" is a subset of the main instance and we need the same data (i.e. BuyerContact) in both instances to submit them in two different xml files. The submissions do their work: the "secondinstance" xml file has all the nodesets and the tags decleared in the "secondinstance" instance, but them are all empty or equal to the "secondinstance" initialization.

      Any idea?

      Thanks!
    • Mark Birbeck
      Hello Alessio and Raoul (!), ... First thing is that anything that uses @ref is binding to only one node - so you can t use unions and such like. However, I
      Message 2 of 2 , Dec 4, 2003
      • 0 Attachment
        Hello Alessio and Raoul (!),

        > does anybody knows how to take data from a single xforms:input
        > and put it in more than one instance? We have tried to use the
        > "|" in the ref="..." attribute of the xforms:input, but it doesn't
        > work well...

        First thing is that anything that uses @ref is binding to only one node
        - so you can't use unions and such like.

        However, I think that XForms actually has a more elegant model to do
        what you want, and that is to use @calculate on an xf:bind. In your
        case, all you need to do is make an xf:bind that makes the value of one
        BuyerContact equal to the value of the other (place this inside your
        xf:model):

        <xforms:bind
        nodeset="BuyerContact"
        calculate="instance('secondinstance')/BuyerContact"
        />

        Any time the value in the second instance changes, the first will also
        change. (See the Hello, World! sample on the formsPlayer site, too.)

        Then you just connect the xf:input to the BuyerContact element that is
        being linked to - in this case, the one in the second instance:

        <xforms:input ref="instance('secondinstance')/BuyerContact">
        <xforms:label>Buyer Contact:</xforms:label>
        </xforms:input>

        Note by the way that xf:label goes *inside* a form control!

        Regards,

        Mark
      Your message has been successfully submitted and would be delivered to recipients shortly.