Component with public property with Collection type #388
-
A Modal Component with a Collection as public property can not be created and fails with Line 97 in 0f64fc4 class AddNewParticipants extends ModalComponent
{
public Collection $participants;
public function mount(array $participants = [])
{
$this->participants = User::findMany($participants);
}
} <button
wire:click="$dispatch('openModal', { component: 'add-new-participants', arguments: { participants: [2, 4, 5] } })"
>
@lang('Add')
</x-button> The Modal tries to resolve the parameter In this case, I would like to care of resolving the parameters in the mount method and skip the resolving of the Modal Component. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think this is because the argument matches the public property. Try using IDs and computed properties instead, for example: class AddNewParticipants extends ModalComponent
{
public $participantsIds;
#[Computed]
public function participants()
{
return User::findMany($participantsIds);
}
} <button
wire:click="$dispatch('openModal', { component: 'add-new-participants', arguments: { participantsIds: [2, 4, 5] } })"
>
@lang('Add')
</x-button> |
Beta Was this translation helpful? Give feedback.
I think this is because the argument matches the public property. Try using IDs and computed properties instead, for example: