2012-10-05 41 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將執行的操作,而不是隻讀的表單字段。這通常非常容易創建評論頁面,在這裏您向用戶顯示在提交之前輸入的所有值。