PHP8: error with number condition

Pigna 01 Mar, 2022
Hi!

In a form I've this condition: if {var:model.name} == 1 the element is visible.

The value in the db is 0 or 1.

WIth J3, CFv7, PHP7 it works, so with J4, CFv7, PHP7.

With J4, CFv7, PHP8 I receive this error:

0 - number_format(): Argument #1 ($num) must be of type float, string given

I can change 0/1 with n/y or others value, anyway I think it's a bug.

p.
Colnem 01 Mar, 2022
Hi

Is it personal table or a joomla table in your db?
What is the field format in your table?
Pigna 01 Mar, 2022
Personal table, tinyint.
Colnem 01 Mar, 2022
1 Likes
Thanks.

Trying on one personal table with a tinynt field, using Run conditions, I haven't any error...

if {var:model.name} == 1 the element is visible.

Is there a php code?
Pigna 02 Mar, 2022
Answer
Yes, it's a php code problem.

With PHP8 i need to change code like $var = number_format($var, 2, ',', '.') in $var = number_format((int)$var, 2, ',', '.').

Thank's.
Colnem 02 Mar, 2022
Hi

In php, you can't use {var:model.name}
You have to use this syntax:
varPhp=$this->get("name_of_var_cf7","");

But to do what you want, you can use CF7 Event, no need PHP.

Bye
You need to login to be able to post a reply.