October: Repeater with file upload

Created on 24 Feb 2017  路  11Comments  路  Source: octobercms/october

I don't know if it is a bug of not... But repeater doesn't works well with file uploader... All because it does not create the new one field to every repetition...

Here an example:
image
(it's an result after upload different images and saving)

Maybe the problem is on my Model:
image

It's because I need to create an personalized gallery that main contian not only images but videos too (v铆deos added with Vimeo code)... Soo I need to add some extra fields what is not possible with the "Gallery widget"... Here is something wrong from my side? Or it's necessary to create my own widget?

Most helpful comment

Use the mediafinder widget within a repeater because it stores a location of the file and not a database relation. The fileupload widget uses the system_files table and connects via a polymorphic relation to the main record. That type of relationship can't be setup through a repeater's contents, so you'll have to use the mediafinder widget to store the location of the file in the repeater widget's data column.

All 11 comments

Use the mediafinder widget within a repeater because it stores a location of the file and not a database relation. The fileupload widget uses the system_files table and connects via a polymorphic relation to the main record. That type of relationship can't be setup through a repeater's contents, so you'll have to use the mediafinder widget to store the location of the file in the repeater widget's data column.

@LukeTowers Hi there! I confirm that mediafinder works as expected in repeater. Although, I wonder if you will eventually provide a workaround to also have file uploader works in repeater, in the future. Thanks in advance.

Also, is there a way to at least allow mediafinder to insert multiple files/images and not just one?

I can't see how that would work to enable the fileupload widget within the repeater simply by virtue of how it is built right now. You'd be trying to connect the system_files relationship to a "fake model" so to speak of a single repeater item.

There isn't a way to make a single mediafinder insert multiple images as that would require assumptions about how the user setup their database, but you could simply put the mediafinder within a repeater within the main repeater.

Example:

photo_albums:
    type: repeater
    form:
        fields:
             album_title:
                  label: 'Album title'
             album_photos:
                  label: 'Album photos'
                  type: repeater
                  form:
                      fields:
                          image:
                              type: mediafinder

@itsam multiple image selection support is coming to the mediafinder soon.

Fantastic news! Thank you for your effort. Really appreciated.

@LukeTowers Does it mean that we will be able to add multiple images thanks to the new media finder, or the media finder will become incompatible with repeater too because it deal with system_files table ?

@Alex360hd you will be able to add multiple images because of the media finder, it will still not use the system_files table nor will it use relationships. It will not become incompatible with the repeater.

Hello,

Thank you for your great effort on october cms. I use it in nearly all of my projects. I wish the best of luck to all of you.

In a case where multiple users with multiple permissions using the media finder and same pool of files, there is a problem. Yes we can create image selector in a repeater field, but what if we still want to keep the files uploaded secret? I mean, media finder shows us a pool of files, so we can select the file inside the repeater, bu what if we need to hide the files uploaded before, or we need to keep the file as it is, without renaming risk of any other user? It seems that it is not easy to implement file upload in repeater, but clearly that would be great for some edge cases.

@taylankoca that is possible by writing your own plugin to dynamically change the media folder root depending on the current user so they can only ever see their own files. How exactly you go about doing that depends entirely on your project's specific needs but it is possible with some knowledge of how the internals work.

You could even make it so that the media library root folder was based on the specific record being edited to help deal with the issue of multiple users with access to a specific record needing to be able to see any images added to repeaters through that record.

Was this page helpful?
0 / 5 - 0 ratings