Categories > TinyButStrong general >

atttrue regards (int) 0 as 'true'.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sheepy
Date: 2013-09-11
Time: 12:27

atttrue regards (int) 0 as 'true'.

Found something interesting in handling of atttrue.

First, the code:

include( 'tbs_class.php' );
$TBS = new clsTinyButStrong();
$TBS->Source = '<input> [fld.0; att=input#value; atttrue] <input> [fld.1; att=input#value; atttrue] <input> [fld.2; att=input#value; atttrue]';
$TBS->MergeField( 'fld', [false, 0, '0'] );
$TBS->Show();

As title stated, what is interesting is that (int) 0 will be rendered as true when atttrue is used.

Problem is the Boolean field of MySQL and Bit field of MS-SQL both returns 1 or 0, instead of true or false.
So regardless of actual value, that field is always true as far as atttrue is concerned, unless we do condition/formatting on either TBS or SQL.

This happens because 0 is casted to '0' at line #1390 after ope processing, before if.then.else processing, but also before att processing.
False is as expected, because it is converted to empty string.  However att sees that '0' is non-empty and think it is true.

If this is not by design, would it be tricky to fix?
By: Skrol29
Date: 2013-09-14
Time: 22:59

Re: atttrue regards (int) 0 as 'true'.

Hi Sheepy,

Thank for the bug report and the nice precisions.

I think it will be fixed soon.
I beta is already n the road.