We have an issue with the field readonly behaviour in Orbeon Forms. We usually write conditions in the bind definitions to tell when a field should be readonly, so when the condition is met, the field on the form(HTML browser) will not be editable.
However, in the HTML Page source of the field we see that the field holds up the property disabled="disabled" but not readonly="readonly". Because of the property disabled="disabled" the data in the input field will be shown in grey color(IE Browser, windows default appearance) and it looks blurred/dull and hence is not viewable correctly. Also we cannot change the color of the input data by css properties for disabled fields, but we can do for fields having property readonly="readonly".
So the question is when we say readonly="true" in bind definition in Orbeon code, is it possible to get property as readonly="readonly" instead of disabled="disabled" for a field on the HTML browser
Sample Orbeon Code and HTML page source snapshot is below
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<xhtml:head>
<xforms:model xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema" id="main-model">
<xforms:instance id="form-instance">
<form>
<field-1></field-1>
<field-2></field-2>
<field-3></field-3>
</form>
</xforms:instance>
<xforms:instance id="form-attributes">
<attributes>
<summary>false</summary>
</attributes>
</xforms:instance>
<xforms:bind id="summary" nodeset="instance('form-attributes')/summary" />
<xxforms:variable name="summary" select="instance('form-attributes')/summary" />
<xforms:bind nodeset="instance('form-instance')" readonly="$summary='true'" />
<xforms:bind id="field-1" nodeset="instance('form-instance')/field-1" />
<xforms:bind id="field-2" nodeset="instance('form-instance')/field-2" />
<xforms:bind id="field-3" nodeset="instance('form-instance')/field-3" />
</xforms:model>
</xhtml:head>
<xhtml:body>
<table>
<tr>
<td>
<xforms:trigger appearance="minimal" id="readonly-view">
<xforms:label>Readonly View</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue bind="summary" value="'true'" />
</xforms:action>
</xforms:trigger>
</td>
<td>
<xforms:trigger appearance="minimal" id="editable-view">
<xforms:label>Editable View</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue bind="summary" value="'false'" />
</xforms:action>
</xforms:trigger>
</td>
</tr>
<tr>
<td>
Field 1:
</td>
<td>
<xforms:input bind="field-1" id="field-1-id" xxforms:maxlength="10" />
</td>
</tr>
<tr>
<td>
Field 2:
</td>
<td>
<xforms:input bind="field-2" id="field-2-id" xxforms:maxlength="10" />
</td>
</tr>
<tr>
<td>
Field 3:
</td>
<td>
<xforms:input bind="field-3" id="field-3-id" xxforms:maxlength="10" />
</td>
</tr>
</table>
</xhtml:body>
</xhtml:html>
Snap shot of the HTML page source:
At this point, as you noticed, Orbeon Forms generates
disabled="disabled"
on read-only form fields, notreadonly="readonly"
, and this cannot be changed without changing Orbeon Forms.A possible solution to your problem is to use the static appearance for read-only controls, which just shows the values of fields, in a way similar to what an
xf:output
would do, rather than the read-only form field. This is typically useful for very easily creating review pages, where you show users all the values they entered before submitting them.