Typo3:Flux& DisplayCond

时间:2016-06-27 19:25:50

标签: typo3 flux fluid

我有以下Flux模板:

<f:section name="Configuration">
  <flux:form id="galleria" enabled="TRUE" label="Galleria image & video plugin">
    <flux:form.sheet name="data" label="Images / Videos">
        <flux:form.section name="settings.items" label="Items" inherit="0">
            <flux:form.object name="item" label="Gallery item" inherit="0">
                <flux:field.select name="type" label="Type"
                                            items="{0: 'Please select', 1: 'Image', 2: 'Video', 3: 'IFrame', 4: 'Flickr', 5: 'Picasa', 6: 'Folder', 7: 'File Collection'}"
                                            default="0"
                                            requestUpdate="TRUE"/>
<f:debug>{type}</f:debug>
                <f:comment>Image configuration fields</f:comment>
                <flux:field.file name="original" label="Main image" displayCond="FIELD:type:=:1"
                                          required="TRUE"/>
            </flux:form.object>
        </flux:form.section>
    </flux:form.sheet>
 </flux:form>
</f:section>

displayCond不起作用。即使我从选择列表命名类型中选择图像,也从未显示输入字段。 调试语句的输出显示“NULL”

如何将displayCond与flux中的字段一起使用:form.object?

2 个答案:

答案 0 :(得分:1)

您正在使用requestUpdate="TRUE"。这很好,所以你可以使用以下内容:

<f:if condition="{type}==1">
 <flux:field.file .... />
</f:if>

<f:if condition="{type}==2">
 [...]
</f:if>

<f:if>不仅适用于预览或主要部分。您也可以在配置部分中使用它。

答案 1 :(得分:0)

注意:这不适用于TYPO3 7.6.x,但仅适用于6.2.x.

我做了这个最小的例子FCE,它的工作原理。只要您在配置部分中,就不需要遍历section.object结构。

在许多情况下,

type是一个保留名称,它并没有详细说明属性行为。因此我将其更改为mediatype

<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
     xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
     xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
     xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers">
    <f:layout name="Content" />

    <f:section name="Configuration">
        <flux:form id="example" label="displayCond example" enabled="1">
            <flux:form.section name="slides" label="slides">
                <flux:form.object name="slide" label="slide">


                    <flux:field.select name="mediatype" label="Media type"
                        items="{0: 'Please select', 1: 'Image', 2: 'Video', 3: 'IFrame', 4: 'Flickr', 5: 'Picasa', 6: 'Folder', 7: 'File Collection'}"
                        default="0"
                        requestUpdate="TRUE"/>

                    <flux:field.input name="title" 
                        label="Title" 
                        displayCond="FIELD:mediatype:=:1" />

                </flux:form.object>
            </flux:form.section>
        </flux:form>
    </f:section>
    <f:section name="Preview">
    </f:section>
    <f:section name="Main">
    </f:section>
</div>

希望这适合你!