R – How to get an XForm to display a checkbox

xforms

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 can't 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 referring to for display is:

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

Best Solution

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" />
    
Related Question