php in Body code with ccv5

How to fix PHP code in a ChronoForms v5 connection view that always executes the else condition.

Overview

The issue occurs because the curly bracket syntax for form data placeholders cannot be used directly within PHP code.
Replace the curly bracket placeholders with the correct PHP array syntax to access the form data, and consider upgrading to ChronoForms v6 for new connections.

Answered
ChronoForms v5
mc mcasamassima 10 May, 2017
I have the following code in my connection view settings in body:
The if statement always return to the 'else', although {operatori_economici} = 2. What is wrong?

<?php

echo "<tr>";

if ('{operatori_economici.numero_incarichi}' > 0)
echo "<td bgcolor='red'> ".'{operatori_economici.numero_incarichi}'."</td>";
else {
echo "<td>".'{operatori_economici.numero_incarichi}'."</td>";
echo </tr>;
?>

I have read the post on this forum but did not solve my problem!
Max_admin Max_admin 11 May, 2017
Answer
1 Likes
Hi mcasamassima,

You can't use the curly brackets syntax in PHP, you need to use the PHP format, I think the following code should work in v5:

if($row["operatori_economici"]["numero_incarichi"] > 0){
//code here
}


And its advised to use v6 for new connections.

Best regards,
Max
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.