Array to string conversion with PHP8.0

Resolve an array to string conversion error in ChronoForms after upgrading to PHP 8.0.

Overview

The error occurs because a function attempts to perform a string operation on an array value, which PHP 8.0 handles more strictly than previous versions.
Modify the specified helper file by adding a conditional check to ensure the operation only runs on string values, preventing the warning.

Answered
ChronoForms v7
ro rojteatern 27 Dec, 2022
When upgrading to PHP8.0 I get this error when loading a CF7-form:

Warning: Array to string conversion in /storage/content/25/4000325/biljett.rojteatern.nu/public_html/administrator/components/com_chronoforms7/chronoforms/helpers/field.php on line 115

Not visible with PHP7.4

The update to CF7.0.10 doesn't make any difference.

Regards
Dennis
ro rojteatern 02 Jan, 2023
Answer
By suggestion from https://www.chronoengine.com/users/profile/115455 (Colnem) I altered the line 115 in "/administrator/components/com_chronoforms7/chronoforms/helpers/field.php" from "$value = str_replace('#'.$loop_name, $loop_index, $value);" to "if (is_string($value)) $value = str_replace('#'.$loop_name, $loop_index, $value);".

Problem Solved!

Thanks!
ro rojteatern 05 Feb, 2024
Hi Max,
I hope ths issue wil be adressed as well in the coming update of CF7.

//Dennis
This topic is locked and no more replies can be posted.