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.
why PHP ? you can use {data:field_name} in normal conditions
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
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
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?
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
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
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
enable the form debug and check the generated SQL, does it show the conditions ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Actually it started working. Thank you so much.
How do I reference the form field data within the php conditions?
$this->data("field_name")
and you can other actions data vars using
$this->get("action_name")
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.