filament/filament
3.2.115
11.9
3.0
8.2.16
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"
]
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.
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
https://github.com/stuartcusackie/filament-wizard-header-scroll-issue
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too