【问题标题】:Force empty repeated section强制清空重复部分
【发布时间】:2019-09-30 13:27:21
【问题描述】:

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

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

我正在使用 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. 首次加载后所需的重复部分

【问题讨论】:

  • 我不确定了解情况。当您为该表单加载/new 页面时,重复部分的第一次迭代不应该为空,除非您为某些字段设置了一些默认值?您能否提供您所看到内容的屏幕截图?
  • @avernet 我已经编辑了这个问题并附上了图片以试图解释这种行为
  • 知道了,我想我明白了,并在下面发布了您的问题的答案。当然,如果我以某种方式误解了您的问题,请随时在 cmets 中告诉我。

标签: orbeon


【解决方案1】:

您可以在“部分设置”对话框中进行配置,单击“无最小值”单选按钮,该按钮在下面的屏幕截图中突出显示,并删除表单生成器中的第一次迭代

我不确定 2017.1.1(您提到的您正在使用的版本)中的状态是什么,但请注意,2018.2.2 中存在一个问题,阻止在最后一个部分之后创建新的部分迭代迭代已被删除。此问题已修复,并将包含在 2018.2.3 版本中。有关该问题的信息,请参阅#4018

【讨论】:

  • 嗨,@avernet 谢谢,但这正是我所拥有的配置,除了“冻结重复”部分,它看起来不包含在此版本中。我会尝试做一些解决方法,因为我的限制是我们使用的是属于 SAP 的其他平台中包含的 Orbeon 版本,并且集成已经由他们完成。我不知道是否可以在不升级产品的情况下升级 Orbeon。
  • @HCP 确实,SAP 提供的 Orbeon Forms 版本可能不是最新版本,但根据我的经验,他们非常擅长在发布产品之前升级 Orbeon Forms。话虽如此,在我看来,您不希望在加载表单时不显示迭代。为此,您不需要“冻结重复”;您只需将最小值设置为“无最小值”,然后删除表单生成器中的第一次迭代。这是有道理的,还是我误解了你的目标?
  • 有关冻结某些重复的更多信息,请参阅文档的Freeze repetitions 部分。
  • 你是对的“你只需将最小值设置为“无最小值”,并删除表单生成器中的第一次迭代”我必须删除表单生成器的第一次迭代,现在是时候了在这我觉得真的很愚蠢。谢谢!我将编辑您的回复并添加此部分。
  • @HCP 太好了,我很高兴这有效,感谢您的更新。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-29
  • 2019-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多