Forums

CF 6 How tu read Database and fill input fields of the form

Peter48 16 May, 2017
Hello! When manually changing a multi-page form CF5 to CF6, I have the problem that I can not automatically fill the address fields of the form with the data that I read from the address database. Basically, the user enters his member identification on the first page of the form. The access to the address database and the address data (including the first name, last name, address, etc.) are triggered by this member identification. The second page of the form is filled with the found data. The names / IDs are identical on the address database and in the form.

In CF5 I used the action [DB Read]
- Table name: t_afo_mitgliederverwaltung
- Conditions: <? Php returnArray ('#mitglied' => $ form -> data ("suchbegriff1")); ?>

==> result: the form fields are filled automatically!

In CF6, I use the [Read Data]
- Model name: member
- Tabel name: t_afo_member administration
- Where conditions: <? Php return [["#mitglied", $ this-> data ("suchbegriff1")]]; ?>
- Select type: First matching record.
- Paging for multipe results: Enable

==> According to the debugger the data recorder is found and read out
==> the form fields are not filled.

Please, can you help me?
Max_admin 16 May, 2017
1 Likes
Hi Peter,

In v6 there is one extra step, the "Data provider" in the "display section" must take the data set of the "read data", e.g:
{var:read_data_action_name}

You could also set the conditions like this:
#mitglied:{data:suchbegriff1}

but its strange to have "#" at the table fields ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Peter48 17 May, 2017
Hi Max

Many thanks for the answer.

The command {var: read_data_action_name} must, in my opinion, be supplemented by the module name:

{Var: read_dat_action_name.ModuleName}
example: {var: read_data6.Model}

-> read_data_action = name corresponds to the black folder: exampel [name: read_data6]
-> Module_name = name corresponds to the selected module name (if the module name is left blank, the system will automatically assigns the name 'Modules'.

Thanks also for the note regarding the where condition. A and / or condition is also possible

Example:

name: {data: keyword1}
first name: {data: keyword2}
or
mitgliednr: {data: keyword1}

In this context, I still have a connection question. Is it also possible to make a query using LIKE

for example: where name like '% xyz%'

What is the syntax?

Thank you in advance for your support.

Peter
Max_admin 17 May, 2017
Answer
1 Likes
Hi Peter,

Yes, its actually like you wrote:

{var:read_data6.Model} //no space after the :

The like can be done this way:

name/like:%{data:keyword1}%


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Peter48 18 May, 2017
1 Likes
Hello Max


Thank you for your support. Accessing with «like» works perfectly. CF6 convinces me and I hope that in the near future a detailed description with examples regarding the new functions will be available. CF6 deserved this!
You're doing a good job - thank you!

Peter
tshirley 23 May, 2017
Hi there,

Could you please say why the where condition syntax is different now?

<? Php return [["#mitglied", $ this-> data ("suchbegriff1")]]; ?> (CF6) works but

<? Php returnArray ('#mitglied' => $ form -> data ("suchbegriff1")); ?> (the CF5 syntax) doesn't work in CF6?

It seems like the CF5 condition is still valid for php code but is not correct for CF6.

Cheers

Tim
Max_admin 24 May, 2017
Hi Tim,

This has been improved, please use the new syntax, in most cases php is not needed:

field_name:{data:url_parameter}


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pat01 02 Jul, 2018
Hi Max

I use a hidden field to store the user id in the form. After I want to fill the form fields automatically by connecting to user table and using following condition:
id:{data:userid}

But it's not working. If I remove the condition, the form loads the data of first user in database table.

Why does the condition not work?

Thank you.

Regards
Patrick

CF 6
healyhatman 02 Jul, 2018
1 Likes
Please don't do that, that's a terrible idea. The hidden field is easily changed and doing it your way means any user can VERY easily get the data for every other user.


Just use {user:id} each time you want to get and use the user id.

as in
id:{user:id}
pat01 02 Jul, 2018
Thanks a lot for the hint! Works fine (I removed the hidden field ;-) )
De Palo 25 Dec, 2018
I'm trying to make a multipage form where into the first step, I started with the demo "Auto Completer". into debug I see get only one value - id, but I'd like to obtain some other value of the table:
id
name
surname
code
country
and display them into read-only field
Thanks
healyhatman 26 Dec, 2018
What does your "fields to retrieve" look like in your database read?
This topic is locked and no more replies can be posted.