Modal Blade component has a problem with Nesting Components

Package Other Package Version v3.0.0 How can we help you? parent component
@foreach ($opportunitys as $opportunity)
<livewire:company.opportunity.item :$opportunity :key="$opportunity->id" />
@endforeach
@foreach ($opportunitys as $opportunity)
<livewire:company.opportunity.item :$opportunity :key="$opportunity->id" />
@endforeach
child component
<x-filament::modal id="show-lost">

<form wire:submit="onLost">
<x-filament::button type="submit" class="float-right">保存</x-filament::button>
</form>
</x-filament::modal>
<x-filament::modal id="show-lost">

<form wire:submit="onLost">
<x-filament::button type="submit" class="float-right">保存</x-filament::button>
</form>
</x-filament::modal>
class Item extends Component
{
public $opportunity;
public $opportunityId;
public function render()
{
return view('livewire.company.opportunity.item');
}


public function showLost($id){
$this->opportunityId = $id;
$this->dispatch('open-modal', id: 'show-lost');
}

public function onLost()
{
dd($this->opportunityId);
}

}
class Item extends Component
{
public $opportunity;
public $opportunityId;
public function render()
{
return view('livewire.company.opportunity.item');
}


public function showLost($id){
$this->opportunityId = $id;
$this->dispatch('open-modal', id: 'show-lost');
}

public function onLost()
{
dd($this->opportunityId);
}

}
In showLost(), the value of $this->opportunityId is available, but the value of $this->opportunityId is not available in onLost(), it is null If Nesting Components is not used. then everything is fine. May I ask how this problem can be solved? Is it a bug?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server