Adobe 使用必填字段创建自定义aem表单字段

Adobe 使用必填字段创建自定义aem表单字段,adobe,aem,Adobe,Aem,我正在尝试使用guidetextbox(文本框)作为基础创建自定义表单字段。在放置自定义逻辑之前,我为组件创建了一个文件夹,并在其中放置了.content.xml,如下所示: <?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="

我正在尝试使用guidetextbox(文本框)作为基础创建自定义表单字段。在放置自定义逻辑之前,我为组件创建了一个文件夹,并在其中放置了.content.xml,如下所示:

<?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)来测试这一点,但该字段仍然是可选的,文本字段周围没有红色边框


有人能告诉我还需要什么吗?

据我所知,您必须在使用该字段的组件的dialog.xml中将该字段设置为必填字段。 通常通过添加

allowBlank="false"

如果您正在使用Touch UI进行对话框,则应在dialog.xml中添加

required="{Boolean}true"
allowBlank="false"
如果您使用的是旧的ExtJS对话框,那么应该添加

required="{Boolean}true"
allowBlank="false"

作为对话框项的属性。

您不应更改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>


对于AEM表单,您需要设置mandatory=“true”、not required或allowBlank。您可以直接在xml中的字段上执行此操作,也可以通过强制复选框通过表单UI执行此操作。

我假设我应该为经典UI对话框使用
allowBlank=false
。@Genesis确实,对于“old Ext Js dialogs”,我这里指的是经典UI。“allowBlank”肯定设置为字符串值“true”或“false”,或者这些值应该是布尔型的?我不认为它必须是布尔型的。它与默认类型String一起工作。