How to handle naming conflicts for dynamic table forms

What is the best way to handle tables that contain forms? I’m getting naming conflicts that are resulting in [object Object] being added to hidden fields.

For example - I have a form where I’m left-joining to get items assigned:

In my table, I’m binding to a server connect object that does a left join to the fields I want populated. Basically, when someone clicks ‘enabled’ - I want to add a new record to the table.

However, when I’m databinding the hidden field, it’s binding to something else on the page.

Here’s what’s happening:

I’ve tried using this pattern:

but it’s not rendering correctly:

What kind of data is res_automation_id? Probably an object seeing the output. Check the response from the server, the dataset used for the repeater.

For the names in the form elements you should use special names, something like my_input[] will create an array while my_input[id] will create an object with a property id. So you probably want to do something like in the post you mentioned. Which naming you have to use depends on how you handle it server-side.

Thanks Patrick! That helped me figure it out.

For anyone else who finds this post here’s some more info for clarity:

  • The real field from the database is called ‘automation_id’ (it’s a PK from a table).
  • I am posting a form to a service and I have a hidden field name called ‘automation_id’
  • When binding the data, it was setting ‘object [Object]’ in the value in my hidden form fields.

I used Patrick’s suggestion above to set the field name to ‘automation_id[$index]’

Here’s a full example of binding a server control select in a table and posting an array back to a server control (which I couldn’t find a good example for.)

  1. Databind the fields and update the name/id binding to represent an array (i.e. field_name[0])
  2. In your server connect process, create an array for your field names and loop through one of them:
  3. On the insert statement, reference the index for the array:
1 Like