Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Besides multiple composite elements, advanced users should be able to build custom table containing individual elements.
@see https://drupal.stackexchange.com/questions/258478/populating-webform-tables
Proposed resolution
Add table support back into the Webform UI
Here a prototype of the YAML source
table:
'#type': table
'#header':
- title: 'First Name'
attributes: { }
- title: 'Last Name'
attributes: { }
- title: Gender
attributes: { }
- title: 'US Citizen'
attributes: { }
'#row__key': table_row_{00}
'#row__title': Table row {0}
'#row__elements':
table_{00}_first_name:
'#title': '{0} - First name'
'#title_display': invisible
'#type': textfield
'#size': 30
table_{00}_last_name:
'#title': '{0} - Last name'
'#title_display': invisible
'#type': textfield
'#size': 30
Remaining tasks
- Add markup support to composite widget
- Add table webform element
- Allow row elements to created in UI (w/ markup)
- You must use 00 in the name of the row element so that each row element is incremented correctly.
- Only allows table row elements to be added as children to table.
- Add YAML source validation which ensures that 'table_row' can only be added to a 'table'
- When table row is added to a table copy the elements and add indexes.
- \Drupal\webform\Plugin\WebformElementInterface::getConfigurationFormProperties
- Write tests
- Write change record
- Create video
User interface changes
- webform_table element
- webform_table_row element
- 'Add row' page
- Update the composite element builder
API changes
N/A
Data model changes
N/A
Release notes snippet
TBD
User Acceptance Test
- Confirm Table row is not visible in 'Add element' UX.
/admin/structure/webform/manage/table_test/element/add - Create a test webform
/admin/structure/webform - Add Table element
- Add Table row element
- Add Textfield to table row
- Add Elements to table row
- Add Table row element with duplicate checked
- Enable for Preview
/admin/structure/webform/manage/{webform}/settings/form - Test the form and click 'Preview'
/webform/{webform}/test - Check Table element #states support
- Check Table row element #states support
Comment | File | Size | Author |
---|---|---|---|
#27 | 3119817-27.patch | 0 bytes | jrockowitz |
#24 | 3119817-24.patch | 64.22 KB | jrockowitz |
| |||
#22 | 3119817-22.patch | 58.86 KB | jrockowitz |
| |||
#18 | 3119817-18.patch | 57.85 KB | jrockowitz |
#12 | 3119817-12.patch | 40.75 KB | jrockowitz |
|
Comments
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI just want to see if this patch is going to break anything.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #22
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #24
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #27
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #29
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented