ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Chronoforms7 "Read Data" Action - php conditions

M
mayergreenberg259 posted Nov 17, 2023 at 06:42
In chronoforms 7, there is a 'Read Data' acton.
Inside the 'Read Data' action there is an advanced setting called "php conditions" which lets one "add where conditions to the sql statement using php".
Can someone show me how this works? I have not been able to get it to work.
My final goal is to use the php to read a form's input value, and use that value in the where condition. If someone could show me how to do that, it would be much appreciated.
Thank you.
Max_admin posted Nov 18, 2023 at 01:14
why PHP ? you can use {data:field_name} in normal conditions
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
M
mayergreenberg259 posted Nov 19, 2023 at 06:01
Thank you so much. That worked.

Can you answer my other question at https://www.chronoengine.com/forums/topics/view/110871/how-can-i-link-more-tables-in-the-read-data-action-in-a-chronoconnectivity7-form#p402103
M
mayergreenberg259 posted Nov 19, 2023 at 06:11
I also have another question:
Is it possible to make the where condition optional?
I would like to have a form with some inputs, which, when submitted, query's the database with the inputs being used in the where conditions.
But I only want the where clause to limit the search when the input in the form is filled out. So I want the where clause to use the input when the input has a value, but when there is no value I want the where clause to be ignored and just return all values. Is this possible?
Max_admin posted Nov 19, 2023 at 13:38
To have conditions optional you need to use PHP conditions and build the conditions array based on the data you need, conditions are returned as an array:
return [["column1", "value1", "="],["column2", "value2", "!="]];
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
M
mayergreenberg259 posted Nov 21, 2023 at 01:12
Answer
It hasn't worked for me. Here is how I did it:
return [["VoidPayments.Reason", "22222", "="],["CreditCardPayment.CreditCardId", "1", "="]];

VoidPayments and CreditCardPayment are the tables and Reason and CreditCardId are the columns in their tables.

Is there another syntax I should be using?

Thank you
Max_admin posted Nov 21, 2023 at 01:22
enable the form debug and check the generated SQL, does it show the conditions ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
M
mayergreenberg259 posted Nov 21, 2023 at 01:37
1 Likes
Actually it started working. Thank you so much.
How do I reference the form field data within the php conditions?
Max_admin posted Nov 21, 2023 at 01:44
$this->data("field_name")

and you can other actions data vars using

$this->get("action_name")
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
You need to login to be able to post a reply.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com