This post was updated on .
I have 2 radio button controls, control-2 and control-4. Each have 3 options, Yes, No and N/A.
If I select the option of Yes for control-2 then I am only allowed to select Yes or No on control-4. If I select the option No for control-2 then I am only allowed to select No on control-4. If I select the option N/A for control-2 then I am only allowed to select N/A on control-4. I was thinking in the case of the No and the N/A options being selected I could have the control changed to readonly and set the initial value to be like the code below and I was thinking of trying to set xxforms:default to be No if No is selected and N/A if N/A is selected. Last but not least i need to disable the N/A option when Yes is selected. Note: The current xxforms:default line isn't well-formed xml so it doesn't work. <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:exforms="http://www.exforms.org/exf/1-0" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:saxon="http://saxon.sf.net/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:odt="http://orbeon.org/oxf/xml/datatypes" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:p="http://www.orbeon.com/oxf/pipeline"> <xhtml:head> <xhtml:title>Untitled Form</xhtml:title> <xforms:model id="fr-form-model"> <xforms:instance id="fr-form-instance"> <form> <section-1> <control-1/> <control-2/> <control-3/> <control-4/> </section-1> </form> </xforms:instance> <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')"> <xforms:bind id="section-1-bind" nodeset="section-1"> <xforms:bind id="control-1-bind" nodeset="control-1" name="control-1"/> <xforms:bind id="control-2-bind" nodeset="control-2" name="control-2" type="xforms:string"/> <xforms:bind id="control-3-bind" nodeset="control-3" name="control-3"/> <xforms:bind id="control-4-bind" nodeset="control-4" name="control-4" type="xforms:string" readonly="../control-2 = 'N/A' or ../control-2 = 'No'" xxforms:default="if ($control-2 = 'N/A') then 'N/A' else if ($control-2 = 'No') then 'No' else null "/> </xforms:bind> </xforms:bind> <xforms:instance id="fr-form-metadata" xxforms:readonly="true"> <metadata> <application-name>buttontest</application-name> <form-name>buttontest</form-name> <title xml:lang="en">Untitled Form</title> <description xml:lang="en"/> <author/> <logo mediatype="" filename="" size=""/> </metadata> </xforms:instance> <xforms:instance id="fr-form-attachments"> <attachments> <css mediatype="text/css" filename="" size=""/> <pdf mediatype="application/pdf" filename="" size=""/> </attachments> </xforms:instance> <xforms:instance id="fr-form-resources" xxforms:readonly="false"> <resources> <resource xml:lang="en"> <control-1> <label>button</label> <hint/> <help/> <alert/> </control-1> <control-2> <label>Customer Information</label> <hint/> <help/> <alert/> <item> <label>Yes</label> <value>Yes</value> </item> <item> <label>No</label> <value>No</value> </item> <item> <label>N/A</label> <value>N/A</value> </item> </control-2> <control-3> <label>test</label> <hint/> <help/> <alert/> </control-3> <control-4> <label>Have Customer Information:</label> <hint/> <help/> <alert/> <item> <label>Yes</label> <value>Yes</value> </item> <item> <label>No</label> <value>No</value> </item> <item> <label>N/A</label> <value>N/A</value> </item> </control-4> <section-1> <label>Untitled Section</label> <help/> </section-1> </resource> </resources> </xforms:instance> <xforms:action id="button-change-binding"> <xforms:action ev:event="DOMActivate" ev:observer="control-1-control"> <xxforms:variable name="control-2-name" select="'control-2'" as="xstring"/> <xforms:setvalue ref="instance('fr-form-instance')/*/*[name() = $control-2-name]" value="null"/> </xforms:action> </xforms:action> </xforms:model> </xhtml:head> <xhtml:body> <fr:view> <xforms:label ref="instance('fr-form-metadata')/title"/> <fr:body> <fr:section id="section-1-section" bind="section-1-bind"> <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:trigger xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" id="control-1-control" bind="control-1-bind"> <xforms:label ref="$form-resources/control-1/label"/> <xforms:help ref="$form-resources/control-1/help"/> <xforms:hint ref="$form-resources/control-1/hint"/> <xforms:alert ref="$fr-resources/detail/labels/alert"/> </xforms:trigger> </xhtml:td> <xhtml:td> <xforms:select1 xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" appearance="full" id="control-2-control" bind="control-2-bind"> <xforms:label ref="$form-resources/control-2/label"/> <xforms:hint ref="$form-resources/control-2/hint"/> <xforms:help ref="$form-resources/control-2/help"/> <xforms:alert ref="$fr-resources/detail/labels/alert"/> <xforms:itemset nodeset="$form-resources/control-2/item"> <xforms:label ref="label"/> <xforms:value ref="value"/> </xforms:itemset> </xforms:select1> </xhtml:td> </xhtml:tr> <xhtml:tr> <xhtml:td> <xforms:input xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" id="control-3-control" bind="control-3-bind"> <xforms:label ref="$form-resources/control-3/label"/> <xforms:hint ref="$form-resources/control-3/hint"/> <xforms:help ref="$form-resources/control-3/help"/> <xforms:alert ref="$fr-resources/detail/labels/alert"/> </xforms:input> </xhtml:td> <xhtml:td> <xforms:select1 xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" appearance="full" id="control-4-control" bind="control-4-bind"> <xforms:label ref="$form-resources/control-4/label"/> <xforms:hint ref="$form-resources/control-4/hint"/> <xforms:help ref="$form-resources/control-4/help"/> <xforms:alert ref="$fr-resources/detail/labels/alert"/> <xforms:itemset nodeset="$form-resources/control-4/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> Any help, examples or guidance would be great. |
Administrator
|
Kevin,
Here is a solution. For the "Have Customer Information" field, set the following: - Constraint: if ($control-2 = ('No', 'N/A')) then . = $control-2 else . = ('Yes', 'No') - Initial Value: leave blank - Calculated Value: if ($control-2 = ('No', 'N/A')) then $control-2 else . There are a few tips here. With Form Runner, other form controls' values are available via variables. So the value of control with name "control-2" is available via $control-2. In XPath you can compare a single value with a sequence of values. So: $control-2 = ('No', 'N/A') is a shortcut for: $control-2 = 'No' or $control-2 = 'N/A' So the Constraint expression above means the following: - if the value of control-2 is either "No" or "N/A", then the current control is valid if its value is the same as that of control-2 - otherwise (control-2 is "Yes"), the current control is valid if its value if "Yes" or "No" The calculated value enforces that: - if control-2 is set to "No" or "N/A", then the current control is set to that same value "No" or "N/A" - otherwise, the value of the current control is not modified (case where control-2 is set to Yes) -Erik On Tue, Feb 21, 2012 at 1:17 PM, krowe <[hidden email]> wrote: > I have 2 radio button controls, control-2 and control-4. Each have 3 options, > Yes, No and N/A. > > If I select the option of Yes for control-2 then I am only allowed to select > Yes or No on control-4. > > If I select the option No for control-2 then I am only allowed to select No > on control-4. > > If I select the option N/A for control-2 then I am only allowed to select > N/A on control-4. > > I was thinking in the case of the No and the N/A options being selected I > could have the control changed to readonly and set the initial value to be > like the code below and I was thinking of trying to set xxforms:default to > be No if No is selected and N/A if N/A is selected. Last but not least i > need to disable the N/A option when Yes is selected. > > > Note: The current xxforms:default line isn't well-formed xml so it doesn't > work. > > <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" > xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" > xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" > xmlns:exforms="http://www.exforms.org/exf/1-0" > xmlns:fr="http://orbeon.org/oxf/xml/form-runner" > xmlns:saxon="http://saxon.sf.net/" > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:odt="http://orbeon.org/oxf/xml/datatypes" > xmlns:sql="http://orbeon.org/oxf/xml/sql" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:oxf="http://www.orbeon.com/oxf/processors" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:xforms="http://www.w3.org/2002/xforms" > > xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary" > xmlns:xi="http://www.w3.org/2001/XInclude" > xmlns:ev="http://www.w3.org/2001/xml-events" > xmlns:p="http://www.orbeon.com/oxf/pipeline"> > <xhtml:head> > <xhtml:title>Untitled Form</xhtml:title> > <xforms:model id="fr-form-model"> > > > <xforms:instance id="fr-form-instance"> > <form> > <section-1> > <control-1/> > <control-2/> > <control-3/> > <control-4/> > > </section-1> > </form> > </xforms:instance> > > > <xforms:bind id="fr-form-binds" > nodeset="instance('fr-form-instance')"> > <xforms:bind id="section-1-bind" nodeset="section-1"> > <xforms:bind id="control-1-bind" nodeset="control-1" > name="control-1"/> > <xforms:bind id="control-2-bind" nodeset="control-2" > name="control-2" type="xforms:string"/> > <xforms:bind id="control-3-bind" nodeset="control-3" > name="control-3"/> > <xforms:bind id="control-4-bind" nodeset="control-4" > name="control-4" type="xforms:string" > readonly="../control-2 = 'N/A' or > ../control-2 = 'No'" > xxforms:default="if ($control-2 = 'N/A') > then 'N/A' else if ($control-2 = 'No') then 'No' else null "/> > > </xforms:bind> > </xforms:bind> > > > <xforms:instance id="fr-form-metadata" xxforms:readonly="true"> > <metadata> > <application-name>buttontest</application-name> > <form-name>buttontest</form-name> > <title xml:lang="en">Untitled Form</title> > <description xml:lang="en"/> > <author/> > <logo mediatype="" filename="" size=""/> > </metadata> > </xforms:instance> > > > <xforms:instance id="fr-form-attachments"> > <attachments> > <css mediatype="text/css" filename="" size=""/> > <pdf mediatype="application/pdf" filename="" size=""/> > </attachments> > </xforms:instance> > > > > <xforms:instance id="fr-form-resources" > xxforms:readonly="false"> > <resources> > <resource xml:lang="en"> > <control-1> > <label>button</label> > <hint/> > <help/> > <alert/> > </control-1> > <control-2> > <label>Customer Information</label> > <hint/> > <help/> > <alert/> > <item> > <label>Yes</label> > <value>Yes</value> > </item> > <item> > <label>No</label> > <value>No</value> > </item> > <item> > <label>N/A</label> > <value>N/A</value> > > > > > </item> > > > </control-2> > <control-3> > <label>test</label> > <hint/> > <help/> > <alert/> > </control-3> > <control-4> > <label>Have Customer Information:</label> > <hint/> > <help/> > <alert/> > <item> > <label>Yes</label> > <value>Yes</value> > </item> > <item> > <label>No</label> > <value>No</value> > > > > > </item> > <item> > <label>N/A</label> > <value>N/A</value> > > > > > </item> > </control-4> > <section-1> > <label>Untitled Section</label> > <help/> > </section-1> > > </resource> > </resources> > </xforms:instance> > > > <xforms:action id="button-change-binding"> > > <xforms:action ev:event="DOMActivate" > ev:observer="control-1-control"> > <xxforms:variable > name="Customer_Notify_Alarm_Company-name" select="'control-2'" > as="xstring"/> > > <xforms:setvalue > ref="instance('fr-form-instance')/*/*[name() = > $Customer_Notify_Alarm_Company-name]" > value="null"/> > </xforms:action> > </xforms:action> > > </xforms:model> > </xhtml:head> > <xhtml:body> > <fr:view> > <xforms:label ref="instance('fr-form-metadata')/title"/> > <fr:body> > <fr:section id="section-1-section" bind="section-1-bind"> > <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:trigger > xmlns:xbl="http://www.w3.org/ns/xbl" > > xmlns:fb="http://orbeon.org/oxf/xml/form-builder" > id="control-1-control" > bind="control-1-bind"> > <xforms:label > ref="$form-resources/control-1/label"/> > <xforms:help > ref="$form-resources/control-1/help"/> > <xforms:hint > ref="$form-resources/control-1/hint"/> > <xforms:alert > ref="$fr-resources/detail/labels/alert"/> > </xforms:trigger> > > </xhtml:td> > <xhtml:td> > <xforms:select1 > xmlns:xbl="http://www.w3.org/ns/xbl" > > xmlns:fb="http://orbeon.org/oxf/xml/form-builder" > appearance="full" > id="control-2-control" > bind="control-2-bind"> > <xforms:label > ref="$form-resources/control-2/label"/> > <xforms:hint > ref="$form-resources/control-2/hint"/> > <xforms:help > ref="$form-resources/control-2/help"/> > <xforms:alert > ref="$fr-resources/detail/labels/alert"/> > <xforms:itemset > nodeset="$form-resources/control-2/item"> > <xforms:label ref="label"/> > <xforms:value ref="value"/> > </xforms:itemset> > </xforms:select1> > </xhtml:td> > </xhtml:tr> > <xhtml:tr> > <xhtml:td> > <xforms:input > xmlns:xbl="http://www.w3.org/ns/xbl" > > xmlns:fb="http://orbeon.org/oxf/xml/form-builder" > id="control-3-control" > bind="control-3-bind"> > <xforms:label > ref="$form-resources/control-3/label"/> > <xforms:hint > ref="$form-resources/control-3/hint"/> > <xforms:help > ref="$form-resources/control-3/help"/> > <xforms:alert > ref="$fr-resources/detail/labels/alert"/> > </xforms:input> > </xhtml:td> > <xhtml:td> > <xforms:select1 > xmlns:xbl="http://www.w3.org/ns/xbl" > > xmlns:fb="http://orbeon.org/oxf/xml/form-builder" > appearance="full" > id="control-4-control" > bind="control-4-bind"> > <xforms:label > ref="$form-resources/control-4/label"/> > <xforms:hint > ref="$form-resources/control-4/hint"/> > <xforms:help > ref="$form-resources/control-4/help"/> > <xforms:alert > ref="$fr-resources/detail/labels/alert"/> > <xforms:itemset > nodeset="$form-resources/control-4/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> > > Any help, examples or guidance would be great. > > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Complicated-Validation-with-radio-buttons-tp4408339p4408339.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > 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 > -- 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 |
Hi Erik,
I have a case where a section is readonly based on an option that the user selects. So if I use the following Constraints for this case, I get an alert on the field when I submit. I don't allow any values to this field if it is readonly. - Constraint: if ($control-2 = ('No', 'N/A')) then . = $control-2 else . = ('Yes', 'No') - Initial Value: leave blank - Calculated Value: if ($control-2 = ('No', 'N/A')) then $control-2 else . Can I ignore this message and not display it if the field is readonly? I also tried: Constraint: if ($control-2 = ('No', 'N/A',null)) then . = $control-2 else . = ('Yes', 'No') Calculated Value: if ($control-2 = ('No', 'N/A')) then $control-2 else . Any help would be great! |
Administrator
|
Kevin,
You could write the constraint this way to make it pass when the control is readonly: if (exforms:readonly(.)) then true() else if ($control-2 = ('No', 'N/A')) then . = $control-2 else . = ('Yes', 'No') (Note that you have to be careful when using functions such as exforms:readonly() etc. from binds: in many cases, order of evaluation is important, and those functions won't work as you expect. Here things should work ok as validation follows the evaluation of the readonly property.) Best regards, -Erik On Mon, Mar 5, 2012 at 7:01 AM, krowe <[hidden email]> wrote: > Hi Erik, > > I have a case where a section is readonly based on an option that the user > selects. > > > So if I use the following Constraints for this case, I get an alert on the > field when I submit. I don't allow any values to this field if it is > readonly. > - Constraint: if ($control-2 = ('No', 'N/A')) then . = $control-2 else > . = ('Yes', 'No') > - Initial Value: leave blank > - Calculated Value: if ($control-2 = ('No', 'N/A')) then $control-2 else . > > Can I ignore this message and not display it if the field is readonly? > > I also tried: > Constraint: if ($control-2 = ('No', 'N/A',null)) then . = $control-2 else . > = ('Yes', 'No') > Calculated Value: if ($control-2 = ('No', 'N/A')) then $control-2 else . > > Any help would be great! > > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Complicated-Validation-with-radio-buttons-tp4408339p4446340.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > 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 > -- 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 |
Free forum by Nabble | Edit this page |