php error after upgrade Joomla 4 and php 8.1

Resolve undefined constant error in CF after Joomla 4 and PHP 8.1 upgrade.

Overview

The error occurs because PHP 8.1 enforces stricter syntax, treating unquoted array keys as undefined constants.
Ensure all string array keys in your custom PHP code are enclosed in quotes.

Answered
ChronoForms v7
wi wiva 26 Feb, 2023
After upgrade to Joomla 4 and php 8.1 one of my forms gives an error
in the form i use a PHP event to validate an arrray of dropdown fields to be unique.
before the update this form was oke. Now i get this error : [0 Undifined constant "ip"]
this is the php code.
Who can help me?
// an array of drop-down names:
$dropdowns=array(
$this->data[ip][0][renner],
$this->data[ip][1][renner],
$this->data[ip][2][renner],
$this->data[ip][3][renner],  
$this->data[ip][4][renner],  
$this->data[ip][5][renner],
$this->data[ip][6][renner],
$this->data[ip][7][renner],
$this->data[ip][8][renner],
$this->data[ip][9][renner],
$this->data[ip][10][renner],
$this->data[ip][11][renner],
$this->data[ip][12][renner],
$this->data[ip][13][renner],
$this->data[ip][14][renner],
);

$dropdowns = array_unique($dropdowns);
if ( count($dropdowns) < 15 ) {
  return fail;
 } else {
 return success;  
 }
Max_admin Max_admin 27 Feb, 2023
Answer
Yes, both "ip" and "renner" should be placed between quotes because they are strings
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.