add components wich contain different value in a form

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

add components wich contain different value in a form

Ilan Cohen

Dear all,

 

I’m using Orbeon form builder and I’m trying to set a button which allows form users to add single-line text component in their form.

 

I’ve seen many samples for this task and the program is almost successful. Here is the code I use :

 

        <xforms:model id="fr-form-model">

            ……

            …..

            <xforms:instance id="fr-form-instance">

                <form>

                    <sectiondate>

                        <date/>

                        <button_ADDdate/>

                    </sectiondate>

                </form>

            </xforms:instance>

             …….

        </xforms:model>

    ….

 

    <xhtml:body>

    …..

                                <xforms:repeat nodeset="date">

                                    <xforms:input bind="date-bind" incremental="true" id="date-control">

                                        <xforms:label ref="$form-resources/date/label"/>

                                    </xforms:input>

                                </xforms:repeat>

                            </xhtml:td>

                            <xhtml:td>

                                <xforms:trigger>

                                    <xforms:label ref="$form-resources/button_ADDdate/label"/>

                                    <xforms:insert ev:event="DOMActivate"  nodeset="date" at="1">                                                  

                                    </xforms:insert>

                                </xforms:trigger>

…..

</xhtml:body>

 

The button does work. It adds the component however, when a user want to set a value in one of the single-line text, the others single-line text, added by the button ,automatically take the same value.

 

I also tried to deal with instance and template in my model and to use  the attributes context and origin in the “xforms:insert” but it still doesn’t work because I probably use a wrong code.

 

Looking forward to get your responses. Thanks

 

Ilan

 

 



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: add components wich contain different value in a form

Alessandro Vernet
Administrator
Ilan,

Ilan Cohen wrote
                                <xforms:trigger>

                                    <xforms:label
ref="$form-resources/button_ADDdate/label"/>

                                    <xforms:insert ev:event="DOMActivate"
nodeset="date" at="1">                                                   

                                    </xforms:insert>

                                </xforms:trigger>

The button does work. It adds the component however, when a user want to set
a value in one of the single-line text, the others single-line text, added
by the button ,automatically take the same value.
This is how <xforms:insert> is supposed to work: it copies the last node pointed by your nodeset, and copies it. To get around this, you need to either:

* Reset the content of the nodes in the node you copied, after copying it (<xforms:setvalue ref="/path/to/node"/>).
* Instead of copying the last node, copy a node from another "template" instance which you keep empty, and which is there just to be copied (this is what the <fr:repeat> does).

Alex