Skip to content

Builder / Repeater field support #596

@piotrku

Description

@piotrku

Filament Version

v.3.2.x

Plugin Version

v3.7.3

PHP Version

PHP 8.3.x

Problem description

Hi, I suppose this is not supported (yet?) or I'm doing something wrong.
I want my media to be kept in the media / media_items table.
This is because I use this Repeater in a (Filament) Builder::make('content_flexible') where content_flexible is a one big JSON field to hold all the Builder Blocks content, so I need more flexibility and cannot create a separate image field for each image.

So I'm using here the MorphAble approach and Repeater to create slides. I use maxItems(1) to limit one image per slide but still using MorphAble.

Repeater::make('slides')
    ->schema([
        TextInput::make('label'),
        CuratorPicker::make('Slide media')
            ->multiple()
            ->relationship('media', 'id')
            ->typeValue('slide_media')
            ->maxItems(1),
])

The problem here is that all images for this slider end up in the media_items table with the same typeValue('slide_media') so I end up with one image because all have the same typeValue - is there some workaround this issue?

Expected behavior

I'd like to have a mechanism for automatic typeValue() generation - so the images within the repeater could be uniquely identified.
I tried to use Closure to put some dynamic value her typeValue() but that ends with an error that string is required and Closure is allowed.

Steps to reproduce

Try to use the CuratorPicker with MorphAble with a Repeater or Block when using the same block type with CuratorPicker multiple times.

Reproduction repository

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions