gal007
gal007

Reputation: 7202

Inserting and updating data in a separate popup in XForms

I'm trying to create a popup to allow the user to edit the detail of an entity. There is a list (a repeat control) of people, and when you click any of their names, the popup should let you edit another data of that person. Something like this drawing:

enter image description here

The only way I managed to do it is to create a hidden div in the form, and show it with JQuery-UI. So, this div is binded to a "temporal person" and once edited, I copy these temporary values to the final list. Something like this:

<people>
    <person name="Alice" age="32" phone="+33..."/>
    <person name="Mike" age="27" phone="+54..."/>
    <person name="Aureline" age="60" phone="+33..."/>
</people>

<tmpPerson  name="" age="" phone=""/>

But the problem is, it is easy just adding new registers, cause I just have to load blank values in the controls (the tmpPerson is blank) and once completed I just have to make an insert with origin... But in the case the registry already exists, it is not easy to load the values... I tryed to use an IF but it doesnt work (neither the alert) and there is no "else" statement. So, how can I determine if I have to load a registry or not?

<xf:trigger id="loadExistingValues">
    <xf:label>Load values</xf:label>
    <xf:action ev:event="DOMActivate"
        if="not(instance('people')/person[@id='Mio')">
            <xf:alert>Here should be the code for a new person creation</xf:alert>
    </xf:action>
</xf:trigger>

I mean, I know I can read via Javascript the data model, search for a person with name "Mio" and if it does exist, load the values also via JS, but if I have to insert a new "person" I can't do it just with JS, so the only thing I can imagine is to create a trigger with XForms actions for creation, and trigger it from JS. But all this stuff sounds SO complex. Maybe anyone can help me with ideas or a simple example? I coudn't find any demo like this!

Upvotes: 0

Views: 115

Answers (1)

Alain Couthures
Alain Couthures

Reputation: 1523

You should give a try to dialog which is a new feature in XForms 2.0 which is already partially supported in XSLTForms.

Upvotes: 1

Related Questions