Form field (text input) keeps taking data from my table from same field

Hi there,

I have two components on my tabbed container.

  1. A table (which includes a field called company_name)
  2. A form - which is inputing to the data displayed in this table

The table displays the data in company_name and the field is inserting a new record, including the field company_name

However - when I load the tabbed container /app - the text input - which should be blank, is taking on the data from the first row of the table (because they are named the same).

I tried just renaming the text input field (under Form data key) - but by doing this, the data never inserts into my db.

Hopefully this makes sense and someone can help. It's a simple task I am sure.

thanks,
Neil

Note that if you change the key and NOT the id it may not see the information entered in the input_company_name field... the form field key is self referential...
Screenshot 2023-01-03 at 11.55.36 AM

1 Like

Hi Scott,
thanks for your quick reply.

I'm not sure I fully understand (sorry - very new to this).

But when I tried ot change the field to be {{self.id}} in the form data key field - it didn't work. It indeed did not show the first row of the table - but it didn't insert a record either :frowning:

thanks again, Neil

OK so you have the table of data, that when a row is selected; the rows column values should be populated into the form to the right and that form should insert a new record to the database?

OR

Is the form submitting new data that the table on the left will eventually display?

Hi Scott,
Second option - sorry, I should have been clearer.

It's a bit messy the now - and the form will be more user friendly in future, but yes, one displays, the other adds (and then will be displayed).

Neil

ok so you need to make sure that the names of the fields in the form correspond with the columns in the database when using thee GUI mode and inserting an object...
Screenshot 2023-01-03 at 12.44.22 PM

And this is the db column names

1 Like

Hi Scott,

thanks again.

Yes - they do - and the record inserts correctly.
But that is the problem ...... the column in the table is also the same name - so for some reason, the first row in the table is pre-filling the text in put box on the right hand side - and that's what I'm trying to solve...... I don't want that.

So, I removed the Form data key - which stops the problem, but then also stops the insert.......

Hopefully i'm making sense. Happy to send a video if it helps,

thanks again,
Neil

Hi @maillme,

Looking through, it does seem like you'll want the form's text input data key to be {{self.id}}

It would be helpful to see exactly what happens with the write query when you change it to {{self.id}} (how does the form data evaluate, is there an error, etc)

Additionally, I'm curious what the form's initial data field is

1 Like

I got it working.

Yes, indeed - I had forgot to rename the input on the form to match the db name.
It is working now!

thanks Scott et al

1 Like

Oh awesome! Glad to hear :slightly_smiling_face:

Thanks @ScottR

1 Like

Tess, could i ask for an explanation on what the Form data key is?
I checked the documentation. But, as a newbie - i couldn't work it out. thanks.
Neil

Hi @maillme

Thanks for checking in! The form data key shouldn't need to be changed from the default in most cases.

It is used to determine how you can reference the component's value from the outer form properties:

Technically, you could change it to any string:

1 Like