Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeater's schema method does not bring the current record #14679

Open
josevictor-ultrahaus opened this issue Oct 31, 2024 · 2 comments
Open
Labels

Comments

@josevictor-ultrahaus
Copy link

josevictor-ultrahaus commented Oct 31, 2024

Package

filament/filament

Package Version

3.2.115

Laravel Version

11.9

Livewire Version

3.0

PHP Version

8.2.16

Problem description

It is not possible to access the current item within the schema method in the Repeater, and the entire Repeater state of all items is returned.

->itemLabel(function (array $state) {
                        return new HtmlString(
                            view('filament.components.service-repeater-item')
                                ->with('state', $state)
                                ->render()
                        );
                    })

If you print the $state inside the itemLabel method, you will see something like:

array:3 [▼ // app/Livewire/Opportunity/OpportunityQuote.php:39
  "icon" => "heroicon-m-archive-box"
  "name" => "Move"
  "description" => "Sea, Air, Road, Storage"
]

Expected behavior

When using:

->schema(function (array $state) {
        dd($state);

The idea was that only the current item would be returned so that it could be used in dynamic components, or that at least the uuid of the current item would be included, so that it could be accessed.

If you print $state, you will see something like:

array:1 [▼ // app/Livewire/Opportunity/OpportunityQuote.php:46
  "efa34400-a95d-4410-a695-e293184ecd3b" => array:3 [▼
    "icon" => "fas-paw"
    "name" => "Pet Transportation"
    "description" => "Dog, Cat, etc..."
  ]
]

So, I need to somehow do the following action:

->schema(function (array $state) {
                        return [
                            // Livewire::make(OpportunityQuoteItem::class, [
                            //     'item' => $state
                            // ]),
                        ];
                    })

Or, do we have some other way to send the data to a custom Livewire component within Repeater?

In the documentation https://filamentphp.com/docs/3.x/forms/advanced#injecting-the-current-state-of-a-field it says that the array $state would give me access to the item current , not the entire state.

Steps to reproduce

Crie um Repeater assim:

Repeater::make('quote_services_repeater')
                    ->label('Serviços Adicionados')
                    ->itemLabel(function (array $state) {
                        dump($state);
                        return new HtmlString(
                            view('filament.components.service-repeater-item')
                                ->with('state', $state)
                                ->render()
                        );
                    })
                    ->schema(function (array $state) {
                        dump($state);

                        return [

                            // Livewire::make(OpportunityQuoteItem::class, [
                            //     'item' => $state
                            // ]),
                        ];
                    })

Tente acessar a última linha adicionada dentro do método schema da forma correta, para que funcione durante a renderização etc

Reproduction repository (issue will be closed if this is not valid)

https://github.com/stuartcusackie/filament-wizard-header-scroll-issue

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar
Copy link

Hey @josevictor-ultrahaus! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Oct 31, 2024
Copy link

Thank you for providing reproduction steps! Reopening the issue now.

@github-actions github-actions bot reopened this Oct 31, 2024
@github-project-automation github-project-automation bot moved this from Done to Todo in Roadmap Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant