How customize Repeater's item using Livewire component?

Livewire 3x.

I have a Livewire component OpportunityQuote that has a Repeater in its structure, like this:

class OpportunityQuote extends Component implements HasForms
{
    use InteractsWithForms, CanGenerateUuids;

    public $quote_services = [];

    public function mount()
    {
        $this->quote_services = [];
        $this->form->fill([
            'quote_services_repeater' => $this->quote_services,
        ]);
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Repeater::make('quote_services_repeater')
                    ->label('Serviços Adicionados')
                    ->itemLabel(function (array $state) {
                        return new HtmlString(
                            view('filament.components.service-repeater-item')
                                ->with('state', $state)->render()
                        );
                    })
                    ->schema(function (array $state) {
                        return [
                            // Livewire::make(OpportunityQuoteItem::class, [
                            //     'item' => $state
                            // ]),
                            TextInput::make('name')
                                ->email()->label('Email'),
                        ];
                    })
                    ->columns(4)
                    ->defaultItems(1)
                    ->collapsible()
                    ->collapsed()
                    ->orderable(false)
                    ->addable(false)
            ])->statePath('quote_services');
    }

    public function onAddedService($item, $index)
    {
        $uuid = $this->generateUuid();
        $this->quote_services['quote_services_repeater'][$uuid] = $item;
        $this->form->fill([
            'quote_services_repeater' => $this->quote_services['quote_services_repeater'],
        ]);
    }
Was this page helpful?