Skip to content

Commit 4a14142

Browse files
authored
[6.x] Hook up "Add Row" config for List fields (#14689)
1 parent 66762e1 commit 4a14142

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

lang/en/fieldtypes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
'link.config.collections' => 'Entries from these collections will be available. Leaving this empty will make entries from routable collections available.',
123123
'link.config.container' => 'Choose which asset container to use for this field.',
124124
'link.title' => 'Link',
125+
'list.config.add_row' => 'Customize the label of the "Add Item" button.',
125126
'list.title' => 'List',
126127
'markdown.config.automatic_line_breaks' => 'Enables automatic line breaks.',
127128
'markdown.config.automatic_links' => 'Enables automatic linking of any URLs.',

resources/js/components/fieldtypes/ListFieldtype.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default {
114114
115115
computed: {
116116
addButton() {
117-
return __(this.config.add_button || 'Add Item');
117+
return __(this.config.add_row) || __(this.config.add_button) || __('Add Item');
118118
},
119119
},
120120

src/Fieldtypes/Lists.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ protected function configFieldItems(): array
2020
'instructions' => __('statamic::messages.fields_default_instructions'),
2121
'type' => 'list',
2222
],
23+
'add_row' => [
24+
'display' => __('Add Row Label'),
25+
'instructions' => __('statamic::fieldtypes.list.config.add_row'),
26+
'type' => 'text',
27+
'placeholder' => __('Add Item'),
28+
],
2329
];
2430
}
2531

tests/Fieldtypes/ListTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public function it_processes()
1818
);
1919
}
2020

21+
#[Test]
22+
public function it_has_add_row_config()
23+
{
24+
$configFields = (new \ReflectionMethod(Lists::class, 'configFieldItems'))->invoke(new Lists);
25+
26+
$this->assertArrayHasKey('add_row', $configFields);
27+
$this->assertSame('text', $configFields['add_row']['type']);
28+
}
29+
2130
private function field($config = [])
2231
{
2332
$ft = new Lists;

0 commit comments

Comments
 (0)