2012-10-05 40 views
0

Orbeon Forms中的字段readonly行为存在问题。我们通常在绑定定义中写入条件来告诉字段何时应该是只读的,所以当条件满足时,表单上的字段(HTML浏览器)将不可编辑。Orbeon Forms中的只读字段行为

但是,在该字段的HTML页面源中,我们看到该字段显示属性disabled =“disabled”,但不是readonly =“readonly”。由于属性disabled =“disabled”,输入字段中的数据将以灰色显示(IE浏览器,Windows默认外观),并且它看起来模糊/无趣,因此无法正确显示。 另外,我们不能通过禁用字段的css属性更改输入数据的颜色,但我们可以为属性为readonly =“readonly”的字段执行操作。

所以现在的问题是,当我们在Orbeon代码绑定定义说只读=“真”,是有可能得到属性为只读=“只读”,而不是禁用=“禁用”关于HTML浏览器

样品Orbeon代码和HTML页面的源快照低于

<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> 
的HTML页面源代码的

快照:

enter image description here

+0

我发现输入文字颜色的CSS不能应用于禁用的字段。 http://reference.sitepoint.com/css/pseudoclass-disabled – Jayy

回答

0

此时,正如您注意到的那样,Orbeon Forms在只读表单字段上生成disabled="disabled",而不是readonly="readonly",并且在不更改Orbeon表单的情况下无法更改。

解决您的问题的一个可能的解决方案是使用static appearance for read-only controls,它只是显示字段的值,类似于xf:output将执行的操作,而不是只读的表单字段。这通常非常容易创建评论页面,在这里您向用户显示在提交之前输入的所有值。