Search code examples
orbeon

Force empty repeated section


I have created a repeated section and by default when form loads first time it shows the section with the first row empty and then it lets to erase this row.

Is there any way to force the section to be completely empty the first time?

I am using Orbeon Forms 2017.1.1.201709122316 PE. This is the code:

<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>

Next images explain what I comment:

  1. Default repeated section after first loading Default repeated section
  2. Desired repeated section after first loading Desired repeated section

Solution

  • You can configure this in the Section Settings dialog, clicking on the "No minimum" radio button, which is highlighted in the screenshot below and remove the first iteration in Form Builder

    I am not sure what the status of this is in 2017.1.1 (the version you mentioned you were using), but note that there was an issue in 2018.2.2 that prevented a new section iteration being created after the last section iteration had been removed. This is fixed, and will be included in 2018.2.3 release. For information on that issue, see #4018.

    "No minimum" radio in the Section Settings dialog