multiple() select not work with afterStateUpdated

generate attribute values based on the selected attributes and add them into the repeater
25 Replies
LeandroFerreira
LeandroFerreira2mo ago
Maybe you could reduce the code to highlight the issue as this topic title. The primary focus should be on a multi-select using the afterStateUpdated method and a simple repeater. I think including unnecessary methods can make the code more complex...
Yacoub Al-haidari
but if i remove the ->multiple() it access to the afterStateUpdated
LeandroFerreira
LeandroFerreira2mo ago
are you using a custom livewire component?
Yacoub Al-haidari
no No just inside filament resource
LeandroFerreira
LeandroFerreira2mo ago
Are you considering using an array as the value for a multiple select, instead of a single string value? Any console errors?
Yacoub Al-haidari
Yes I have the ->options(AttributeValue::where('attribute_id', $attributeId)->pluck('value', 'id')->toArray()) For getting the list of the AttributeValues After i add the ->multiple() the select not works Because I can not Access to the afterStateUpdated for getting the seleted values
LeandroFerreira
LeandroFerreira2mo ago
I can not Access to the afterStateUpdated for getting the seleted values what is the output? null?
Yacoub Al-haidari
No access , no touch the AttributeValues : i want to make this but with multiple() AttributeValues < i will provide you a new video Now
LeandroFerreira
LeandroFerreira2mo ago
no access.. what does it mean? 🤷‍♂️
Yacoub Al-haidari
I mean , I can not access to the afterStateUpdated when the multiple is enable i added the dd() and select the AttributeValues select box but no dd() works in side the afterStateUpdated
LeandroFerreira
LeandroFerreira2mo ago
remove ->reactive() use only ->live()
Yacoub Al-haidari
Still not working
LeandroFerreira
LeandroFerreira2mo ago
doesn't it work?
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->multiple()
->live()
->afterStateUpdated(function ($state) {
dd($state);
})
Select::make('select')
->options([
'1' => 'Option 1',
'2' => 'Option 2',
])
->multiple()
->live()
->afterStateUpdated(function ($state) {
dd($state);
})
Yacoub Al-haidari
Not work < Select::make("attributevalues{$attributeId}") ->label("اختر قيمة الخاصية: " . $attribute->name) ->options(AttributeValue::where('attribute_id', $attributeId)->pluck('value', 'id')->toArray()) ->required() ->multiple() ->dehydrated() ->native(true) ->live(onBlur: true) ->afterStateUpdated(function (Set $set, Get $get, $state) use ($attributeId) { dd($state); $attributeValues = $get('attribute_values') ?? []; $attributeValues[$attributeId] = [$state];
$set('attribute_values', $attributeValues);
$colors = $get('colors') ?? []; $variants = generateVariants($colors, $attributeValues);
$set('Has_variants', $variants); })
LeandroFerreira
LeandroFerreira2mo ago
live, not live onblur everytime you post a different code 🤷‍♂️ did you try my code? Did it work?
Yacoub Al-haidari
this is the full code <<<
Yacoub Al-haidari
It seems strange , works for single select but with multiple select not works I will try
LeandroFerreira
LeandroFerreira2mo ago
probably my code won't work if it is true..
Yacoub Al-haidari
No it's not true , this works fine 🔥 , but my code not LOL 😅
Adnan Yalahow
Adnan Yalahow2mo ago
bro i have struggled this many times what version of filament are you using when i updated the latest version of filament this solution will definitelywork
Yacoub Al-haidari
3.2.80
Adnan Yalahow
Adnan Yalahow2mo ago
Try to clear the cache. I can't see any problem there
Want results from more Discord servers?
Add your server
More Posts
Animation On Action Buttonhi all , i have a question . is that possible to add animation trigger on action button ? example liEasy way to only allow registration and login via Socialite?I am looking for a way to disable login and only show a login or register button with Google/Github/Form in Livewire: Disable Submit-Button, while a file uploads?Hi, im using the Filament Form inside a Livewire component. While **uploading a large file**, the Help, Setting runtime config only for one FileUploadHi firends, Here I have a **FileUpload** that is setupped to work with **S3 pre-signed links** and My issue : After perform delete its not applaying redirectsWhen deleteign a record that uses HasRelationManagers on Edit record page it tells me Call to a memWhen selecting filters in a list of records, the widget does not updateI have an invoice resource and I have added a widget to it to calculate the total of invoices. The wAction group width suddenly becomes out of controlI don't know from where and why my action group menu width has become largen and the menu doesn't fihow to send request and get response inside action buttonIm trying to send get/post request inside action ( button in header section). I tried with route and$get() in Wizard Form is nullHi all ! I have the same problem as this topic : https://discord.com/channels/883083792112300104/115Pass parameter from URL to table header actionHi, is there a way to pass a URL parameter to an action in the table header? For example I'm on the