tags:

views:

50

answers:

2

i seem to be having problems getting a xform to display a check box - instead it is displaying a text area. All my other items are working correctly, i just cant seem to get this one to work.

this is the code inside my model

<takeMoneyOff type="xs:boolean"/>

//close the my structure
//close the instance

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"/>

//close the model

and the item this is all refering to for display is

  <xf:input ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
  </xf:input>

any ideas guys?

thanks

+2  A: 

You don't mention which XForms implementation(s) you are targeting, but assuming that it is / they are fully conformant, you have two options.

  1. If you want to specify the type in the instance data, as your example code indicates, you need the type attribute to be in the XML schema instance namespace. So, if you've declared the namespace prefix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance", your instance datum would need to look like this:

    <takeMoneyOff xsi:type="xs:boolean" />
    
  2. Alternatively, if the instance data is coming from an external source and you're not in control of it, then you can place a type attribute on the bind element itself instead (it should not be in the xsi namespace in this case):

    <xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff" type="xs:boolean" />
    
Phil Booth
+1  A: 

You can also use <xforms:select>, which will store a value or blank:

<xf:select ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
    <xf:item>
        <xf:label>Yes</xf:label>
        <xf:value>true</xf:value>
    </xf:item>
</xf:select1>

With the appropriate bind, you could even store "false" when a blank appears:

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"
         calculate="choose(. = 'true', ., 'false')"
         readonly="false()"/>
ebruchez