Skip to content

Commit 7873d5a

Browse files
committed
add repeatable uploader docs
1 parent 0a299e6 commit 7873d5a

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

7.x-dev/crud-uploaders.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,20 @@ class CustomUploader extends Uploader
9797
return $valueToBeStoredInTheDatabaseEntry;
9898
}
9999

100-
// in case you want to use your uploader inside repeatable fields
101-
protected function uploadRepeatableFiles($values, $previousValues, $entry = null)
100+
// this is called when your uploader field is a subfield of a repeatable field. In here you receive
101+
// the sent values in the current request and the previous repeatable values (only the uploads values).
102+
protected function uploadRepeatableFiles($values, $previousValues)
102103
{
104+
// you should return an array of arrays (each sub array is a repeatable row) where the array key is the field name.
105+
// backpack will merge this values along the other repeatable fields and save them in the database.
106+
return [
107+
[
108+
'custom_upload' => 'path/file.jpg'
109+
],
110+
[
111+
'custom_upload' => 'path/file.jpg'
112+
]
113+
];
103114
}
104115
}
105116
```
@@ -179,9 +190,20 @@ class CustomUploader extends BackpackAjaxUploader
179190
return $valueToBeStoredInTheDatabaseEntry;
180191
}
181192

182-
// in case you want to use your uploader inside repeatable fields
183-
protected function uploadRepeatableFiles($values, $previousValues, $entry = null)
193+
// this is called when your uploader field is a subfield of a repeatable field. In here you receive
194+
// the sent values in the current request and the previous repeatable values (only the uploads values).
195+
protected function uploadRepeatableFiles($values, $previousValues)
184196
{
197+
// you should return an array of arrays (each sub array is a repeatable row) where the array key is the field name.
198+
// backpack will merge this values along the other repeatable fields and save them in the database.
199+
return [
200+
[
201+
'custom_upload' => 'path/file.jpg'
202+
],
203+
[
204+
'custom_upload' => 'path/file.jpg'
205+
]
206+
];
185207
}
186208
}
187209
```

0 commit comments

Comments
 (0)