Smarty foreachelse not working
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PHPDevShell |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Here is a simple example of a problem I am having, where the variable sent to the smarty template is empty but the foreachelse does not seem to work.
So set $RESULTS=false; in controller and then call View.
Here is a sample template file:
{if ''==$RESULTS}
BLANK<br>
{/if}
{if false==$RESULTS}
FALSE1<br>
{/if}
{if false===$RESULTS}
FALSE2<br>
{/if}
{foreach $RESULTS as $result}
Result is {$result}<br>
{foreachelse}
Results are empty!
{/foreach}
Here are the ACTUAL results I am getting:
BLANK
FALSE1
FALSE2
Result is
Notice the IF statements are all confirming the value of $RESULTS is blank/empty, but the foreachelse is not being called.
The expected results should be this, but I can't figure out why it is not working:
BLANK
FALSE1
FALSE2
Results are empty!
Changed in phpdevshell: | |
status: | New → Invalid |
This bug is INVALID ...
I posted question on Smarty forum and got this reply:
$RESULTS is not null or an empty array but has an assigned boolean value of false. This does enter the loop and not the {foreachelse} section. Values of FALSE and of "" (blank string) are NOT the same as being NULL or EMPTY.