I've included a simple form below that displays two drop down select1 controls. The visibility of the second control depends on the value selected in the first one. If you select "Attended" then the second control is visible and you can select a value, anything else and the second control should not be seen.
This works when you create the form but if you select something other than Attended (making the second control invisible) and save the form, the second control's element in the model is deleted. If you then edit the form and set the first value back to Attended the second control is not displayed since it doesn't have a node in the model (at least I assume that is why it doesn't appear). This same form type works correctly in orbeon 4.10. Is there something I can change in the form to make this work correctly? I should be able to edit the form, set the value of the first control back to Attended and the second control should then appear. I don't think making the control invisible should delete the element from the model. thanks, <?xml version="1.0" encoding="UTF-8"?> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:exforms="http://www.exforms.org/exf/1-0" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:im="http://www.infomedix.com.au/cpf/forms" xmlns:saxon="http://saxon.sf.net/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"> <xhtml:head> <xhtml:title>Untitled Form</xhtml:title> <xforms:model id="fr-form-model"> <!-- Main instance --> <xforms:instance id="fr-form-instance"> <form> <section-1> <attendance_status>attended</attendance_status> <mbs_item /> </section-1> </form> </xforms:instance> <!-- Bindings --> <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')"> <xforms:bind id="section-1-bind" name="section-1" nodeset="section-1"> <xforms:bind id="mbs_item-bind" name="mbs_item" nodeset="mbs_item" relevant="../attendance_status = 'attended'" /> <xforms:bind id="attendance_status-bind" name="attendance_status" nodeset="attendance_status" /> </xforms:bind> </xforms:bind> <!-- Metadata --> <xforms:instance id="fr-form-metadata" xxforms:readonly="true"> <metadata> <application-name>CPF</application-name> <form-name>tidbwtest</form-name> <title xml:lang="en">Untitled Form</title> <description xml:lang="en" /> <author /> <logo filename="" mediatype="" size="" /> <im:version>5</im:version> </metadata> </xforms:instance> <!-- All form resources --> <!-- Don't make readonly by default in case a service modifies the resources --> <xforms:instance id="fr-form-resources" xxforms:readonly="false"> <resources> <resource xml:lang="en"> <attendance_status> <label>Attendance Status</label> <hint /> <help /> <alert /> <item> <label>Attended</label> <value>attended</value> </item> <item> <label>Failed to Attend - Discharge</label> <value>failed_to_attend-discharge</value> </item> <item> <label>Failed to Attend - Rebook</label> <value>failed_to_attend-rebook</value> </item> </attendance_status> <mbs_item> <label>MBS Item</label> <hint /> <help /> <alert /> <item> <label>Management Plan (132)</label> <value>management_plan</value> </item> <item> <label>Standard New (110)</label> <value>standard_new</value> </item> </mbs_item> <section-1> <label>Clinic Note</label> <help /> </section-1> </resource> </resources> </xforms:instance> <!-- Utility instances for services --> <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all"> <request /> </xforms:instance> <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all"> <response /> </xforms:instance> </xforms:model> </xhtml:head> <xhtml:body> <fr:view> <xforms:label ref="instance('fr-form-metadata')/title" /> <fr:body> <fr:section bind="section-1-bind" id="section-1-section"> <xforms:label ref="$form-resources/section-1/label" /> <xforms:help ref="$form-resources/section-1/help" /> <fr:grid columns="2"> <xhtml:tr> <xhtml:td> <xforms:select1 xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary" xmlns:xbl="http://www.w3.org/ns/xbl" appearance="full" bind="attendance_status-bind" id="attendance_status-control"> <xforms:label ref="$form-resources/attendance_status/label" /> <xforms:hint ref="$form-resources/attendance_status/hint" /> <xforms:help ref="$form-resources/attendance_status/help" /> <xforms:alert ref="$fr-resources/detail/labels/alert" /> <xforms:itemset nodeset="$form-resources/attendance_status/item"> <xforms:label ref="label" /> <xforms:value ref="value" /> </xforms:itemset> </xforms:select1> </xhtml:td> <xhtml:td> <xforms:select1 xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary" xmlns:xbl="http://www.w3.org/ns/xbl" appearance="minimal" bind="mbs_item-bind" id="mbs_item-control"> <xforms:label ref="$form-resources/mbs_item/label" /> <xforms:hint ref="$form-resources/mbs_item/hint" /> <xforms:help ref="$form-resources/mbs_item/help" /> <xforms:alert ref="$fr-resources/detail/labels/alert" /> <xforms:item> <xforms:label>[Select...]</xforms:label> <xforms:value /> </xforms:item> <xforms:itemset nodeset="$form-resources/mbs_item/item"> <xforms:label ref="label" /> <xforms:value ref="value" /> </xforms:itemset> </xforms:select1> </xhtml:td> </xhtml:tr> </fr:grid> </fr:section> </fr:body> </fr:view> </xhtml:body> </xhtml:html> |
I've done a bit more reading and digging in our old code.
I see that this is the correct default behaviour for a submission and our forms use a custom save button that runs a submission. I added 'relevant="false"' to our submission and now it is not deleting the non-relevant elements from the model. I still have two questions 1) Should the control still work if relevant becomes true on the bind even if it's element is missing in the model? 2) What is the behaviour if I'm using the default form save button rather than my custom submission? thanks |
Administrator
|
Hi Brian,
1) If the node the control points to isn't there, it is then normal for the control not to be visible. 2) With "save", the element is never removed. Removing the element is only useful if you're not going to reuse this data in the context of XForms, for instance because XForms will use the saved rather than submitted data. Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thanks Alex, that makes sense. Our old integration with 3.9 does provide some interesting behaviour from time to time. It is causing me to learn more about xform behaviour!
|
Administrator
|
Brian, you're welcome. And I'm even surprised that 3.9 would show a control bound to a non-existent node. If it did, things wouldn't work that well after that, since the control would have no place to store a new value entered by users. Anyhow, the current behavior is the correct one :).
Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |