When submitting data to a table element, the data does not get saved. Checking the site's logs, there are no errors reported.

I have been able to reproduce this issue with the following form configuration:

table_fieldset:
  '#type': fieldset
  '#title': Table data
  table:
    '#type': table
    '#header':
      - 'Data column 1'
      - 'Data column 2'
      - 'Data column 3'
    '#rows':
      -
        table_1_column:
          data:
            table_data_row_1_col_1:
              '#title': Datafield
              '#title_display': invisible
              '#type': textfield
              '#size': 30
        table_2_column:
          data:
            table_data_row_1_col_2:
              '#title': Datafield
              '#title_display': invisible
              '#type': textfield
              '#size': 30
        table_3_column:
          data:
            table_data_row_1_col_3:
              '#title': Datafield
              '#title_display': invisible
              '#type': textfield
              '#size': 30

Comments

bobby.gry created an issue. See original summary.

jrockowitz’s picture

Status: Active » Closed (works as designed)

The below code is from the 'Example: Layout: Basic' form included in the webform_examples.module.

You just need to remove the 'rows' and 'data' key.

table_example:
  '#type': details
  '#title': Table
  '#open': true
  table:
    '#type': table
    '#header':
      - 'First Name'
      - 'Last Name'
      - Gender
      - 'US Citizen'
    table__1:
      table__1__first_name:
        '#title': '1 - First name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__1__last_name:
        '#title': '1 - Last name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__1__gender:
        '#title': '1 - Gender'
        '#title_display': invisible
        '#type': select
        '#options': gender
      table__1__us:
        '#title': '1 - US Citizen'
        '#title_display': invisible
        '#type': checkbox
    table__2:
      table__2__first_name:
        '#title': '2 - First name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__2__last_name:
        '#title': '2 - Last name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__2__gender:
        '#title': '2 - Gender'
        '#title_display': invisible
        '#type': select
        '#options': gender
      table__2__us:
        '#title': '2 - US Citizen'
        '#title_display': invisible
        '#type': checkbox
    table__3:
      table__3__first_name:
        '#title': '3 - First name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__3__last_name:
        '#title': '3 - Last name'
        '#title_display': invisible
        '#type': textfield
        '#size': 30
      table__3__gender:
        '#title': '3 - Gender'
        '#title_display': invisible
        '#type': select
        '#options': gender
      table__3__us:
        '#title': '3 - US Citizen'
        '#title_display': invisible
        '#type': checkbox
bobbygryzynger’s picture

@jrockowitz - that did the trick, thanks!