Applying 'Database Inserts' to Form

I have built a multi-step form which I am wanting to enter data into a MySQL relational database across 5 tables. I am not sure on how to add the insert behaviours to work with the form, as well as binding the correct relational id’s into the relational tables.

Do I need to add separate server actions for each database table?
How do I integrate the Database inserts with the form?

To explain how this was previously done using DW and Web-assist.

  • An ‘Insert record’ behaviour was created for each table.
  • The Insert behaviour for table with the primary key (id) was triggered first which creates a session id with the value of the primary key.
    -then for each of the next insert behaviours created for the different tables the session id created on each behaviour was used to bind that value as the relational id in the table.

Help Please.
Thanks in advance!

All you need is a single server action added to your server connect form with 5 insert steps inside it, which insert the data in the 5 different tables.

This tutorial shows how to create the insert record action first and then form, but you already have the form created, so just import it in your insert server action and setup the insert steps.

What is throwing me here is it talks about generating the form, but i don’t need the form generated. When I select ‘make server connect form’. Do I just ignore the ‘input fields generators’ ? Plus can you clarify how I can bind the id from one table into another as the relational value?

As explained:

So just skip the generate process. Import your form in the server action and setup the insert steps.

The inserted record ID is available in the dynamic data picker so you can pick it and add it to your other table:

thanks for this @Teodor. One question before I work on this , when you say ‘Import form in the server action’ … How do I do that exactly?

Then your form inputs will be imported under $_POST

Many thanks again @Teodor. I think I get this… May I ask what the ‘Input validation’ is? next to ‘Input Properties’ Where it has ‘Export Validations to form’

It’s a server-side validation for the inputs.

1 Like

Ok thanks @Teodor. and I appreciate your help and patience with me on this. Your Support has been brilliant!

1 Like

@Teodor i’m testing the first insert step but it’s not inserting into database.
Not sure what i’m missing here.
I’ve configured the ‘Insert options’ ( see screenshot )
And I’ve selected the correct action from the ‘Form Properties/server connect form action’

Can you see anything wrong here?

Then please check for errors as explained here:

What database are you using?

sorry @Teodor ignore this for now!