© 2026 Hedgehog Software, LLC
Forms\Components\Select::make('licenses') ->label(__('vmc.licenses')) ->preload() ->relationship('licenses', 'name', fn (Builder $query) => $query->orderBy('name')) ->multiple() ->searchable() ->live() ->afterStateHydrated(function (Component $livewire, ?array $state) { $livewire->dispatch('updatedSelectedLicenses', selectedLicenses: $state); }) ->afterStateUpdated(function (Component $livewire, ?array $state) { $livewire->dispatch('updatedSelectedLicenses', selectedLicenses: $state); })
$license = License::factory()->create(['cost' => 22.1234]); Livewire::test(CreateVirtualMachine::class) ->assertFormFieldExists('licenses') ->set('data.licenses', [$license->id]) ->assertDispatched('updatedSelectedLicenses', ['selectedLicenses' => [$license->id]]) ->assertSee('22,12');
Failed asserting that an event [updatedSelectedLicenses] was fired with parameters: [{"selectedLicenses":[2]}]
Failed asserting that '<bunch of html>' [UTF-8](length: 83059) contains "22,12" [ASCII](length: 5).
$state
22,12
->assertDispatched('updatedSelectedLicenses', selectedLicenses: [$license->id])