I need a table field in my plugin's settings, but when I make 2 rows and save the settings, only the first row is shown when I go back to the settings page. When I dump the values, my second setting is still in there. Here's my code:
{% import '_includes/forms' as forms %}
{% set name, rows = 'myCustomSettingsTableField', [] %}
{% if attribute(settings, name) != null %}
{% for value in attribute(settings, name)[0] %}
{% set rows = rows|merge([value]) %}
{% endfor %}
{% endif %}
{{ forms.editableTableField({
label: 'My Settings Table Field',
id: name,
name: name,
cols: [
{heading: 'Column 1', handle: 'column1', type: 'text'}
{heading: 'Column 2', handle: 'column2', type: 'text'},
],
rows: [rows],
}) }}
Dumping settings.myCustomSettingsTableField
gets me this even though I can only visually see the the first row in the table when I re-enter the settings page.
array(2) {
[0]=>
array(2) {
[0]=>
string(15) "Row 1, column 1"
[1]=>
string(15) "Row 1, column 2"
}
[1]=>
array(2) {
[0]=>
string(15) "Row 2, column 1"
[1]=>
string(15) "Row 2, column 2"
}
}
How do I configure my Twig code so that it saves and displays correctly?