Project

General

Profile

Actions

Bug #89241

closed

NULL doesn't work for ternary conditions in Fluid

Added by Bill Dagou about 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2019-09-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

With {condition ? optionA : optionB} in the Fluid template, and the condition is NULL, it always get optionA instead of optionB.

Actions #1

Updated by Claus Due over 4 years ago

  • Status changed from New to Closed

Depending on how you look at this, it is either by design or could be considered a bug in Fluid. Either way it cannot be solved through a forge request and would have to be reported to the Fluid repository's issue tracker instead.

  • If considered by design: the reason this happens is that the variable is not assigned at all, causing Fluid to use the variable name as a string which then means the condition is true (since 'condition' == true).
  • If considered a bug: Fluid might need to drop the fallback to using a string with the variable name, when the variable is not assigned, for this particular type of expression.

You can also work around it by making sure the variable is assigned:

{f:variable(name: 'condition', value: 0) -> f:else() -> f:if(condition: condition)}

If you consider this a bug then please feel free to report the problem on Fluid's issue tracker: https://github.com/TYPO3/Fluid/issues

- Closing the issue here on forge since it is not related to TYPO3 CMS.

Actions

Also available in: Atom PDF