Hi, I have followed the user guide section http://wiki.orbeon.com/forms/doc/user-guide/form-builder-user-guide/section-templates in order to build a custom section for the purpose of storing contact details. The contact details compromise of: title, first name, surname, telephone numbers, postal address etc. This section has several XPath validation rules so that if you select email as the primary form of contact; a confirmation email address also becomes visible and required. These rules encapsulate the core basic validation rules for the section. The contact section has then been placed in several forms to enable business users to build the forms with little knowledge of XForms, XBL or any related technology. The one issue that we have is that certain forms require
slightly different validation rules for contact data. For example some forms
always require the postal address to be required for the contact detail
section. What is our best option for providing this functionality? 1/ Can we expose access to the individual fields using XBL, so we can overwrite the default section template XPath expressions for the field, postcode required 2/ Can we encapsulate all of the specific strategy rules within the section template, so that the user selects a validation strategy: default or default + mandatory postal address. This way we keep all of the validation rules encapsulated within the section template. Many thanks --You received this message because you are subscribed to the Google Groups "Orbeon Forms" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. |
Administrator
|
Hi Graham,
Good question. The "section template" works by creating for you an XBL component based on a section you declared in a form. The XBL component contains its own xf:bind doing the validation, and by design, XBL components are shielded from the environment they are placed in. In the form that uses the section template, you'll just see: <component:your-template/> I think the cleanest way to do what you're looking for would be to add an attribute where the component is used: <component:your-template zip-mandatory="true"/> In the library form, in the section, add a text output control, set its name to zip-mandatory. We want to set its value based on the value of the zip-mandatory attribute. We can do this by adding a variable, for instance below the control, by editing the source, to get something along these lines: <xh:td> <xf:output id="zip-mandatory-control" bind="zip-mandatory-bind"> <xf:label ref="$form-resources/zip-mandatory/label"/> <xf:hint ref="$form-resources/zip-mandatory/hint"/> <xf:alert ref="$fr-resources/detail/labels/alert"/> </xf:output> <xf:var name="zip-mandatory" xbl:attr="xbl:text=zip-mandatory"> <xf:setvalue ev:event="xforms-enabled" ref="xxf:bind('zip-mandatory-bind')" value="$zip-mandatory"/> </xf:var> </xh:td> Set the visibility of that control to false(), as you don't want it to be really visible to end users. Then in the constraint for your zip code, you can have something like: if ($zip-mandatory = 'true') then . != '' else true(). Note how we refer to the value of the zip-mandatory text output control with $zip-mandatory. Finally, where the section template is used, edit the source to add zip-mandatory="true" or zip-mandatory="false" on the component element. For reference, I've also put the source of the library and form using it on: https://gist.github.com/avernet/6158515. I hope this helps, Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |