Starting a Form

I think I have tables figured out. Now I am starting on Forms.
The documentation seems to be oriented to building a table first, then using a Form for editing.
I am trying to build a Form for adding a record to a table without presenting the table.
But I can't seem to connect the table to the form. I have tried updating the table in the Data component of the form but that has no effect. I would like to add a new row to the table and connect the form fields to that row table.
Is it possible to do this?
Mike

Upon submit of the form, insert a new record to the database and then reload the query that retrieves the data for the table?

Scott:
My problem is there is no default value for the fields on the form to show where the data should be saved.
I cannot assign a default field name because there is no associated table.
Mike

Maybe I misread what you are trying to do.
Can you share some screenshots?

Here is a screen shot. Its a modal form. I have not figured out how to link it to a table.
Mike

Do you want the selected row of the table to populate the fields of the form?

Yes, that would be fine.
What is missing is a connection to a table.
Mike

OK so for each field, Default value should be like the following:
{{yourTableName.selectedRow.data.tableColumnName}}

Here's the default field

Under the submit button, I have:
{{table4.recordUpdates}};
select * from company

The {{table4.recordUpdates}}, does not work.
Elsewhere I have connected table4 back to the MySQL File Company.
Nothing goes back to Company.

Mike

Hopping in here to try helping as well!

Could you share a screenshot of the query that your submit button is running?

The recordUpdates property gets populated with any changed rows on the table. It’s an array of objects, where each object represents an array.

Generally, we would run an update query that passes in recordUpdates then add an additional get query (e.g. SELECT * FROM users) on success of that update query!

Victoria:
I am attaching 4 screen shots.

  1. This shows the form and the table as they appear.
  2. This is the code that links the form to the table. When it first initiates, the form data equals the table data. But updates in the table do you show on the form and vice versa.
  3. Under the Submit button I have code under "OnUpdateRowCust3" which is "TableUpdate".
  4. That same code also has success code that restores the data from the server.

I think the problem is that there is no link between the form and the table.

Mike




{{table4.selectedRow.data.compcont}}. Remove the ? and the ternary it is not needed

Scott:
I tried that and got an error message that
"data was required".
Do you mean remove all the question marks or just some of them?
Mike

Why not make each column in the table editable and then use the table4.recordUpdates in the GUI mode of the query when you are trying to update the records in the table4 component. You don't need the form.

Scott:
There are 14 columns in the company table and some fields are pretty wide. It is not practical to fill this out in table format.
Mike

What does this look like: {{table4.selectedRow.data}} perhaps it should be
{{table4.selectedRow.data[0].compcont}}
If you could share the data from the table that would help me help you more effectively.

I tried this. First it causes an error message at the entry point. (see screen shot below)
And when I tried to run it, there is no link to the table.
Mike

Looking at your last screenshot, I believe you have curly brackets around the 0 instead of hard brackets!

{{table4.selectedRow.data{0}.compcont}}

when it should be...

{{table4.selectedRow.data[0].compcont}}

Does that make a difference at all?

Victoria:
The code that works best for the form connection to the table is shown in the first screen shot. There is no [0]. The form behaves properly and shows whatever is in the selected table row. So I think I am OK there.
The bigger problem is the code under the Submit button. After some delving around I have come up with the code in the next 4 screen shots. It seems like code that should work but it doesn't work. i.e. the selected row of the table does not update with what is on the form.
There is no success event code. Not sure if there should be.
Mike
pict5




That also looks good to me on initial glance! It’s not updating in your db? There should be some indicator of success. Are you getting an error message when running this query?