Daniel Pomrehn
Daniel Pomrehn

Reputation: 855

Typo3: Flux & DisplayCond

I have the following Flux Template:

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

The displayCond does not work. The Input Field is never been shown, even if I select Image from the select List named type. The Output of the debug statement says "NULL"

How can I use displayCond with a field inside a flux:form.object?

Upvotes: 4

Views: 2542

Answers (2)

Naderio
Naderio

Reputation: 1419

You are using requestUpdate="TRUE". This is good, so you can use the following:

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

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

The <f:if> not only works in the preview- or main-section. You can also use it in the configuration-section.

Upvotes: 2

The F
The F

Reputation: 3714

Note: This does not work for TYPO3 7.6.x, but only for 6.2.x.

I made this minimal example FCE and it works. No need to go through the section.object structure as long as you're in the configuration section.

type is a reserved name in many cases and it is not telling much about the properties behaviour. Therefor I changed it to 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>

Hope this works for you!

Upvotes: 0

Related Questions