Repeaters and Blockeditor won't work with media library.

I saw the pst regarding JSON repeaters. So I switched to the block editor for the content that NEEDS some kind of a repeater. How can I achieve this? What should I upgrade or how can I integrate this repeatable medias feature? In our design, there are lots of blocks that needs this.
36 Replies
ifox
ifox10mo ago
I'm not sure what you mean @Hazarcan Doğa, you can create blocks that include repeater fields, in which you can use medias fields Repeaters and blocks perfectly work with the media library. only JSON repeaters don't Repeaters outside of blocks also work with the media library, as long as you are storing the repeated item in a dedicated model, with a hasMany relationship, instead of storing everything in a JSON column (which in most cases is not a great idea)
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
I am not sure that I fully grasp the difference between the JSON repeaters and normal repeaters.
ifox
ifox10mo ago
from a form standpoint they are the same, the difference is where you save it with json repeaters, you save it in a column of your model with a normal repeater you saive it in a separate model
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
For example I think "InlineRepeater" is the json repeater. In which case it doesn't work because fields are saved as a JSON instead of a blockable releationship
No description
ifox
ifox10mo ago
with a foreign key like I said, form is the same for both oh you're in a block??? repeaters in blocks are just children blocks
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
However, this is a block I created, if I use it it will work with media. However when I call it inside a "BlockEditor" form field, again the media relations won't work am IO correct
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Yes
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
I am trying to integrate this block with a repeater of media, browser and multiple text fields.
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
And there are many more structures where I need media inside a repeater, all related to blocks of course. So it is crucial for me to find a work around about this. I need to use medias with repeaters inside blocks. I read the documentation maybe I missed something.
ifox
ifox10mo ago
there is no work around needed to do this. what exactly is not working? did you set a crop configuration for your medias field named bg?
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
What do you mean by repeaters here? the first example in this page? https://twillcms.com/docs/form-fields/repeater.html
Twill
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Of course the issue is, when I use the block like this in BlockEditor FormField
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
These are my crops
No description
ifox
ifox10mo ago
You need a ratio in those crops If you don't want to force any ratio, use 0 or null
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
@ifox I was mistaken, When I used BlockEditor form field and separated the repeater conten into an another block, medias worked fine. However, eventhough I added to ratios to the crops as you suggested, In the editor page, media fields are fetched empty eventhough I know I filled the fields before saving and refreshing the page. The video shows what I mean.
ifox
ifox10mo ago
What's the name of your nested blocks medias field? ha variable_image I guess and it renders on your frontend, I see, so it actually saves correctly I'll try to reproduce
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Yes, it does. The first component is a nested block, second one is normal as you can see, both have the same problem.
ifox
ifox10mo ago
Can you please share the 2 block classes? also, which version of Twill are you on?
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
I was in my lunch break yes sure
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
This is the first block
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Second block (developed in twill 2.0)
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
"version": "3.x-dev",
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
additionally page module class
No description
ifox
ifox10mo ago
In the form for Page, what do you have?
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
This is what I have
No description
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
@ifox do you think that using a blade in the module and formBuilder in blocks would couse this?
ifox
ifox10mo ago
it should not That shouldn't normally be an issue but try naming variable_image inside one of the 2 blocks differently (and a new crop key in config accordingly)
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
I changed one and removed the other block from the page, still the same issue.
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
This is the output of "$this->form($id)" in edit() method of A17\Twill\Http\Controllers\Admin\ModuleController
No description
ifox
ifox10mo ago
I think I got it You're using translated medias fields? And/or changed the main locale of your application?
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Data seems to be like that but normally no I don't use medias to be translated Let me check
ifox
ifox10mo ago
I see tr in the medias keys
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
yes you are correct the system language is in turkish However I don't use translated() option in media fields let me check one thing
ifox
ifox10mo ago
Check twill.media_library config It's enabled globally
Hazarcan Doğa
Hazarcan DoğaOP10mo ago
Yes that was the cause... Thank you very much. One more question, what if I'd use a repeater with a blade template on it's own... would media worked the same way it worked in BlockEditor?
ifox
ifox10mo ago
yes
Want results from more Discord servers?
Add your server