how to set max repeat for a repeater

I want to limit user to upload up to 3 images. I am using the repeater for this. is this best practice ? and if yes how can I limit the user to upload at least one and at most 3 images?
Solution:
You can do this Repeater::make('members') ->schema([ // ... ])...
Jump to solution
4 Replies
Brian Kidd
Brian Kidd11mo ago
Is there a reason you’re using a repeater rather than the file upload form field? The form field can handles these requirements but there may be a specific reason you’re using the repeater. https://filamentphp.com/docs/3.x/forms/fields/file-upload
Solution
JJSanders
JJSanders11mo ago
You can do this Repeater::make('members') ->schema([ // ... ]) ->minItems(2) ->maxItems(5)
KiaBoluki
KiaBolukiOP11mo ago
Thank you for your reply. the main reason is the images and the product models have a one-to-many relationship and the number of images is varied. at least one image is required and the other two images are optional so I decided to give the user the option the number of images they want to upload for their product . I think the repeater is a good tool for this .
KiaBoluki
KiaBolukiOP11mo ago
Thank you this is actually what I was looking for. unfortunately it is not in the documentation. I couldn't find it there at least.
Want results from more Discord servers?
Add your server