I have a radio button control with two items in it.
<xforms:select1 ref="add-delete" appearance="full">
<xforms:item>
<xforms:label>Add</xforms:label>
<xforms:value>A</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label>Delete</xforms:label>
<xforms:value>D</xforms:value>
</xforms:item>
</xforms:select1>
I want to disable only the radio button ‘Delete’ and not the radio button ‘Add’ on condition X. How can I carry out this ?
I tried using class attribute with xforms:item but that is not working. Is there any other way to do this ?
Good question. And unfortunately, this isn’t as easy to do as it should:
If you just wanted the delete radio button to be hidden, instead of disabled, you can replace the
<xforms:item>for the “Delete” by an<xforms:itemset ref="…">that you bind to a node which you make non-relevant when you want that radio button not to show. But you can’t use that same technique to disable the radio button by binding the itemset to a node you make read-only. (And yes, it would be good if you could do that.)As it stands, I think you’ll need to:
<xforms:select1>. One for “Add”, one for “Delete”, so you can make the second one readonly upon some condition.<xforms:select1>, so you need to deselect “delete” when “add” is selected reacting toxforms-select, and vice versa.In the model, you would have:
And in the view:
And see this Gist for the full source of this example.