acabust
How to Pass Dynamic Data from Filament Form to Livewire Component for Price Calculation
I'm trying to create a Livewire component that displays the price of a product within a Filament form. The form allows users to manipulate several select fields (to change color, model, etc.), and each change can affect the price.
My goal is to display the updated price whenever the form values change. I've been using this documentation page as a reference: https://filamentphp.com/docs/3.x/forms/advanced#inserting-livewire-components-into-a-form
Currently, I can pass fixed values to my Livewire component like this:
Forms\Components\Livewire::make(CalculPrixSejour::class, [
'sejour_id' => '33';
]),
However, it seems impossible to use closures directly. This doesn't work:
Forms\Components\Livewire::make(CalculPrixSejour::class, [
'sejour_id' => function (Get $get) {
return $get('sejour_id');
},
]),
It seems odd that I can't pass anything other than fixed values. I must be missing something in the documentation.
6 replies
Bug (visual): RelationManager AssociateAction multiple select field selected options disappear
Couldnt find anything on Google/Github related.
Dont really know where to go from here.
"
Tables\Actions\AssociateAction::make()
->multiple()
->recordSelectSearchColumns(['awb'])
->preloadRecordSelect()
->recordSelect(fn ($select) => $select
->options($orderQuery->get()->pluck('title', 'id'))
->getSearchResultsUsing(fn ($search) => $orderQuery->where('awb', 'like' ,"%$search%")->get()->pluck('title', 'id'))
)
->associateAnother(false)
->successRedirectUrl(fn ($record) => self::getUrl('view', ['record' => $record]))
->action(function ($data) use ($getOwnerRecord, $relationship) {
$getOwnerRecord->{$relationship}()->syncWithoutDetaching($data['recordId']);
$getOwnerRecord->touch();
})
,
"
Using v3.2
3 replies