强制清空重复部分

Force empty repeated section

我创建了一个重复的部分,默认情况下,当第一次加载表单时,它会显示第一行为空的部分,然后它允许删除这一行。

有什么方法可以强制该部分第一次完全清空吗?

我正在使用 Orbeon Forms 2017.1.1.201709122316 PE。这是代码:

<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
         xmlns:ev="http://www.w3.org/2001/xml-events"
         xmlns:exf="http://www.exforms.org/exf/1-0"
         xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
         xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
         xmlns:saxon="http://saxon.sf.net/"
         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
         xmlns:sql="http://orbeon.org/oxf/xml/sql"
         xmlns:xf="http://www.w3.org/2002/xforms"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
         xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
    <xh:head>
        <xh:title/>
        <xf:model id="fr-form-model" xxf:expose-xpath-types="true">

            <!-- Main instance -->
            <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
                <form>
                    <rep-section-1>
                        <rep-section-1-iteration>
                            <control-1/>
                        </rep-section-1-iteration>

                    </rep-section-1>
                </form>
            </xf:instance>

            <!-- Bindings -->
            <xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
                <xf:bind id="rep-section-1-bind" name="rep-section-1" ref="rep-section-1">
                    <xf:bind id="rep-section-1-iteration-bind" ref="rep-section-1-iteration"
                             name="rep-section-1-iteration">
                        <xf:bind id="control-1-bind" name="control-1" ref="control-1"/>
                    </xf:bind>

                </xf:bind>
            </xf:bind>

            <!-- Metadata -->
            <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
                <metadata>
                    <application-name>test</application-name>
                    <form-name>repeated</form-name>
                    <title xml:lang="en"/>
                    <description xml:lang="en"/>
                </metadata>
            </xf:instance>

            <!-- Attachments -->
            <xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
                <attachments>
                    <css mediatype="text/css" filename="" size=""/>
                    <pdf mediatype="application/pdf" filename="" size=""/>
                </attachments>
            </xf:instance>

            <!-- All form resources -->
            <!-- Don't make readonly by default in case a service modifies the resources -->
            <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
                <resources>
                    <resource xml:lang="en">
                        <rep-section-1>
                            <label>Repeated Section</label>
                        </rep-section-1>
                        <control-1>
                            <label>Field1</label>
                            <hint/>
                            <alert/>
                        </control-1>
                    </resource>
                </resources>
            </xf:instance>
            <xf:instance xxf:readonly="true" id="rep-section-1-template"
                         xxf:exclude-result-prefixes="#all">
                <rep-section-1-iteration>
                    <control-1/>
                </rep-section-1-iteration>
            </xf:instance>

            </xf:model>
    </xh:head>
    <xh:body>
        <fr:view>
            <fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline"
                     xmlns:oxf="http://www.orbeon.com/oxf/processors">
                <fr:section id="rep-section-1-control" bind="rep-section-1-bind" repeat="content"
                            template="instance('rep-section-1-template')"
                            apply-defaults="true"
                            fb:initial-iterations="first"
                            collapsible="true">
                    <xf:label ref="$form-resources/rep-section-1/label"/>
                    <fr:grid>
                        <xh:tr>
                            <xh:td>
                                <xf:input id="control-1-control" bind="control-1-bind">
                                    <xf:label ref="$form-resources/control-1/label"/>
                                    <xf:hint ref="$form-resources/control-1/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                </xf:input>
                            </xh:td>
                            <xh:td/>
                        </xh:tr>
                    </fr:grid>
                </fr:section>
            </fr:body>
        </fr:view>
    </xh:body>
</xh:html>

下图解释我的评论:

  1. 首次加载后的默认重复部分
  2. 首次加载后所需的重复部分

您可以在“部分设置”对话框中配置它,单击下面屏幕截图中突出显示的 "No minimum" 单选按钮,然后删除 Form Builder 中的第一个迭代

我不确定它在 2017.1.1(您提到的您使用的版本)中的状态如何,但请注意 2018.2.2 中存在一个问题,阻止在最后一节迭代已被删除。这是固定的,将包含在 2018.2.3 版本中。有关该问题的信息,请参阅 #4018