主要用到displayCond这个标签:
<mode>
<TCEforms>
<label>LLL:EXT:cfa_mooflow/locallang_db.xml:cfa_mooflow.pi_flexform.mode</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<items type=”array”>
<numIndex index=”0″ type=”array”>
<numIndex index=”0″>LLL:EXT:cfa_mooflow/locallang_db.xml:cfa_mooflow.pi_flexform.mode.0</numIndex>
<numIndex index=”1″>MANUAL</numIndex>
</numIndex>
<numIndex index=”1″ type=”array”>
<numIndex index=”0″>LLL:EXT:cfa_mooflow/locallang_db.xml:cfa_mooflow.pi_flexform.mode.1</numIndex>
<numIndex index=”1″>DIRECTORY</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</mode>
<defaultmode>
<TCEforms>
<displayCond>FIELD:mode:=:MANUAL</displayCond>
<label>LLL:EXT:cfa_mooflow/locallang_db.xml:cfa_mooflow.pi_flexform.images</label>
<config>
<type>group</type>
<internal_type>file</internal_type>
<allowed>jpg,gif,png</allowed>
<max_size>100000</max_size>
<uploadfolder>uploads/tx_cfamooflow/</uploadfolder>
<maxitems>100</maxitems>
<size>10</size>
<selectedListStyle>Width:280px</selectedListStyle>
</config>
</TCEforms>
</defaultmode>
详细信息:
Contains a condition rule for whether to display the field or not.
A rule is a string divided into several parts by “:” (colons).
The first part is the rule-type and the subsequent parts will depend on the rule type.
Currently these rule values can be used:
- FIELD : This evaluates based on another fields value in the record.
- Part 1 is the fieldname
- Part 2 is the evaluation type. These are the possible options:
- REQ : Requires the field to have a “true” value. False values are “” (blank string) and 0 (zero) or if the field does not exist at all. All else is true.For the REQ evaluation type Part3 of the rules string must be the string “true” or “false”. If “true” then the rules returns “true” if the evaluation is true. If “false” then the rules returns “true” if the evaluation is false.
- > / < / >= / <= : Evaluates if the field value is greater than, less than the value in “Part 3”
- = / != : Evaluates if the field value is equal to value in “Part 3” (or not, if the negation flag, “!” is prefixed)
- IN / !IN : Evaluates if the field value is in the comma list equal to value in “Part 3” (or not, if the negation flag, “!” is prefixed)
- – / !- : Evaluates if the field value is in the range specified by value in “Part 3” ([min] – [max]) (or not, if the negation flag, “!” is prefixed)
- EXT : This evaluates based on current status of extensions.
- Part 1 is the extension key
- Part 2 is the evaluation type:
- LOADED : Requires the extension to be loaded if Part3 is “true” and reversed if Part3 is “false”.
- REC : This evaluates based on the current record (doesn’t make sense for flexform fields)
- Part 1 is the type.
- NEW : Requires the record to be new if Part2 is “true” and reversed if Part2 is “false”.
- Part 1 is the type.
- HIDE_L10N_SIBLINGS : (FlexForms only) This evaluates based on whether the field is a value for the default language or an alternative language. Works only for <langChildren>=1, otherwise it has no effect.
- Part 1: Keywords: “except_admin” = will still show field to admin users
- HIDE_FOR_NON_ADMINS: This will hide the field for all non-admin users while admins can see it. Useful for FlexForm container fields which are not supposed to be edited directly via the FlexForm but rather through some other interface (TemplaVoilà’s Page module for instance).
- VERSION:
- Part 1 is the type:
- IS : Part 2 is “true” or “false”: If true, the field is shown only if the record is a version (pid == -1)
- Part 1 is the type:
For FlexForm elements the fields are tags on same level. If <langChildren> is enabled, then the value of other fields on same level is taken from the same language.
The field-values of the FlexForm-parent record are prefixed with “parentRec.”. These fields can be used like every other field (since TYPO3 4.3).
Example:
This example will require the field named “tx_templavoila_ds” to be true, otherwise the field for which this rule is set will not be displayed:
'displayCond' => 'FIELD:tx_templavoila_ds:REQ:true',
This example requires the extension “static_info_tables” to be loaded, otherwise the field is not displayed (this is useful if the field makes a look-up on a table coming from another extension!):
'displayCond' => 'EXT:static_info_tables:LOADED:true',
This example would require the header-field of the FlexForm-parent record to be true, otherwise the FlexForm field is not displayed (works only within FlexForm datastructure definitions):
<displayCond>FIELD:parentRec.header:REQ:true</displayCond>