Load fields from DB, allow edit, validate and save back

Load, edit, and save database records in a ChronoForms 8 form.

Overview

The issue occurred because the form container was incorrectly placed inside the "On record(s) found" block, preventing data from displaying, and the save action lacked a proper data source.
Move the form container outside the conditional block to display data. For saving, ensure the Save Data action uses {data:} as the Data Source and a correct WHERE clause to update the specific record.

Answered
ChronoForms v8
bc bcraigie 29 May, 2024

Please can someone explain how I get the data from a database load into the fields of a form in V8?  I have a lot of V5 forms to convert to V8, so just learning the differences.  I want to create a form like this (truncated for this example):

Load fields from DB, allow edit, validate and save back image 1

Load fields from DB, allow edit, validate and save back image 2

I can see with the Debug turned on that the field price_raffle_tickets exists in the loaded data.  But the value does not get to the form.

I think I'm missing something simple, possibly in the Field Name?

I want to ensure that if the user changes the value in the field that it will get written back to the database.  How do I make that link?

Thanks :-)

bc bcraigie 30 May, 2024

I found the answer.  I dragged the Container out of the "On record(s) found" block to below it.  Strange as it was the logical place for it to be.  I only wanted to show the container if the record was found.

I now don't know how to handle the record not being found (ie what do I put in the "On no records found" block so that it doesn't just carry on anyway.  If anyone knows, I'd be grateful for an explanation, and if I figure it out myself, I'll post it here for others. :-)

bc bcraigie 31 May, 2024
Answer
1 Likes

I've now come to try and save the data back.  I want to update the record I just read with the updated data from the form.  In the Submit section in a Save Data block, I've specified a where clause like this:

`id`={data.quote:id}

What I want it to do is update the table with the new values where the id column in the table = the id of the read record (which is 1 in this case).

But I get :

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `id`='1'' at line 1

I've now figured this out too.  I found this help page which I somehow didn't see before.  All I had to do was add {data:} into the Data Source box.

:-)

Brian

P.S. the back ticks are correctly placed before and after id, but the forum has moved them in the display.  Strange.

da darkarturo 15 Jun, 2024
Hello bcraigie, please is there a way to contact you, I also need help please, since I want to do the same as you.. please
This topic is locked and no more replies can be posted.