@snapey Is it right that your instructions are analogue for more than two dynamic cascading menus?
https://talltips.novate.co.uk/livewire/dynamic-cascading-dropdown-with-livewire
My class ist looking like follow:
class Dropdowns extends Component
{
public $system;
public $types=[];
public $typ;
public $arts=[];
public $art;
public $kats=[];
public $kat;
public function mount($system, $typ, $art, $kat)
{
$this->system=$system;
$this->typ=$typ;
$this->art=$art;
$this->kat=$kat;
}
public function render()
{
$systems = Teilsystem::all();
if(!empty($this->system)) {
$this->types = Typ::where('teilsystem', $this->system)->get();
}
if(!empty($this->typ)) {
$this->arts = Art::where('ufertyp', $this->typ)->get();
}
if(!empty($this->art)) {
$this->kats = Kategorie::where('bwart', $this->art)->get();
}
return view('livewire.dropdowns')
->with('systems', $systems);
}
}
in my blade:
@livewire('dropdowns', ['system' => $event->system_id, 'typ' => $event->typ_id, 'art' => $event->art_id, 'kat' => $event->kat_id])
$event is giving the initial values. But unfortunately I can only choose the values of $event. But why?
my include ("dropdowns")
<div class="form-group row">
<label for="systems" class="col-md-4 col-form-label text-md-right">{{__('Bauwerkssystem')}}</label>
<div class="col-md-6">
<select name="systems" wire:model="system" class="form-control" >
<option value=""></option>
@foreach ($systems as $system)
<option value="{{$system->id}}">{{ $system->teilsystemname }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="bw_typ" class="col-md-4 col-form-label text-md-right">{{__('Bauwerkstyp')}}</label>
<div class="col-md-6">
<select name="bw_typ" wire:model="typ" class="form-control" >
<option value=""></option>
@foreach($this->types as $typ)
<option value={{ $typ->id }}>{{ $typ->typ }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="bw_art" class="col-md-4 col-form-label text-md-right">{{__('Bauwerksart')}}</label>
<div class="col-md-6">
<select name="bw_art" wire:model="art" class="form-control" >
<option value=""></option>
@foreach($this->arts as $art)
<option value={{ $art->id }}>{{ $art->bwart }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="bw_kat" class="col-md-4 col-form-label text-md-right">{{__('Bauwerkskategorie')}}</label>
<div class="col-md-6">
<select name="bw_kat" wire:model="kat" class="form-control" >
<option value=""></option>
@foreach($this->kats as $kat)
<option value={{ $kat->id }}>{{ $kat->bwkategorie }}</option>
@endforeach
</select>
</div>
</div>
Thanks for your help
PS: I know, to open a new thread for new questions, but it's addressing you directly ;-) @snapey