Populate text fields from DB based on data in other text fields

Elita- 10 Jan, 2018
Hello, Could somebody give the direction where to look or how to do following:

I have 5 text fields in my CF6 form:

Name
Surname
Birthdate
Code
Number

That match DB table 'DBsaraksts' column names.

I need the code? or some CF6 action/event or whatever (I cannot figure out) to look for the three first fields to mach in DB table and return the Code and Number from the row.

I have managed to perform DB read action and got the array of all DB table records:

Array
(
[read_data4] => Array
(
[log] => Array
(
[0] => SELECT `Kodi`.`Name` AS `Kodi.Name`, `Kodi`.`Surname` AS `Kodi.Surname`, `Kodi`.`Birthdate` AS `Kodi.Birthdate`, `Kodi`.`Code` AS `Kodi.Code`, `Kodi`.`Number` AS `Kodi.Number` FROM `DBsaraksts` AS `Kodi` LIMIT 10000;
)

[var] => Array
(
[Kodi] => Array
(
[Name] => Janis
[Surname] => Berzins
[Birthdate] => 21.01.2001.
[Code] => 23465768
[Number] => JB2345
)

)

)

)

What next? Some PHP code? Where? Or jQuery? How?
Thank you in advance -
Elita
Max_admin 12 Jan, 2018
Hi Elita,

What do you want to do with the data ? how should the form work ? user fills the fields then submits the form, the data is loaded, then ?

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Elita- 13 Jan, 2018
Hi, Max,
I need that this way - when user fills in first three text fields - Name, Surname, Birthdate - these fields should be compared with the data in the DB table, found data for two remaining fields Code, Number and all together should be saved in the new database table. All fields Names are the same as DB column names.
Max_admin 19 Jan, 2018
Hi Elita,

You just need to use the "where conditions" and match the fields to the form input using the {data:form_field_name} shortcode:
table_field:{data:form_field}


Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Elita- 19 Jan, 2018
Hi, Max, still have "black hole" somewhere🙂 sorry.
So, I read data from the DB as you wrote - set the DB Read with the conditions where Name:{data:Name}, etc. That I understand and already did.
Debugger shows that correct data has been retrieved.
But HOW can I get Code and Number fields populated???
Tried to put the value in Designer section like {var:read_data36.Number}, but nothing happens.
Should I put custom code somewhere or custom event that renders that data? Or custom DB save action that take the data from DB read and Save to the nev database?
Max_admin 19 Jan, 2018
Hi Elita,

I'm not sure how your form works, when do you execute the "Read data" ? before or after the form is sent ?

The syntax to get the value from the read data is {var:read_data36.MODEL_NAME.Number}, but this will not return any value if the read data did not run already, it can be used in the "Value" setting of your field!

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