2015-11-11 38 views
0

我正在嘗試使用guidetextbox(文本框)作爲基礎來創建自定義表單字段。把我的定製邏輯之前,我創建了一個文件夾的分量和內我把.content.xml如下:創建具有必填字段的自定義aem表單字段

<?xml version="1.0" encoding="UTF-8"?> 
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" 
allowedParents="[*/parsys, */*layout]" 
componentGroup="Adaptive Form" 
jcr:description="AEM Form Custom input field" 
jcr:primaryType="cq:Component" 
jcr:title="AEM Form Custom input field" 
sling:resourceSuperType="/libs/fd/af/components/guidetextbox"> 

<cq:template 
    jcr:primaryType="nt:unstructured" 
    jcr:title="Custom input" 
    guideNodeClass="guideCustomInput" /> 
</jcr:root> 

我試圖通過設置字段作爲強制性的(從dialog.xml)來測試這一點,但字段保持可選狀態,在文本字段周圍沒有紅色邊框。

有人可以建議還需要什麼嗎?

回答

0

據我所知,你必須在你使用它的組件的dialog.xml中將該字段設置爲強制。 通常這是通過添加

allowBlank="false" 

到dialog.xml做

1

如果您使用的觸摸用戶界面的對話框,您如果使用的是舊Ext JS的對話應該增加

required="{Boolean}true" 

,則應添加

allowBlank="false" 

作爲對話項目的屬性。

0

您不應該更改guideNodeClass屬性,因爲這是AEM表單域的內部工作。它應該保持爲guideTextBox。

另外作爲resourceSuperType不應該是絕對路徑的最佳實踐。最終代碼如下所示

<?xml version="1.0" encoding="UTF-8"?> 
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" 
allowedParents="[*/parsys, */*layout]" 
componentGroup="Adaptive Form" 
jcr:description="AEM Form Custom input field" 
jcr:primaryType="cq:Component" 
jcr:title="AEM Form Custom input field" 
sling:resourceSuperType="fd/af/components/guidetextbox"> 

<cq:template 
    jcr:primaryType="nt:unstructured" 
    jcr:title="Custom input" 
    guideNodeClass="guideTextBox" /> 
</jcr:root> 
0

對於AEM表單,您需要設置mandatory =「true」,不是必需的或allowBlank。您可以直接在xml的字段中執行此操作,也可以通過強制複選框通過Forms UI執行此操作。