order.blade.php (step component)
<div class="mt-2">
<x-input-label for="category" :value="__('Category')" />
<x-input-select wire:model.change="state.category" :options="$categories" name="category" id="category" class="block mt-1 w-full" />
<x-input-error :messages="$errors->get('category')" class="mt-2" />
@if($selectedState === '6')
<x-input-label for="others" :value="__('Specify category')" />
<x-text-input wire:model="state.others" id="others" class="block mt-1 w-full" name="others" :value="old('others')" />
<x-input-error :messages="$errors->get('others')" class="mt-2" />
@endif
</div>
Order.php
public function updatedStateCategory($name, $value)
{
// Something you want
$this->selectedState = $name;
}
如果选择其他选项,则显示文本输入,但刷新或提交表单时,输入消失
selectedState必须在渲染视图之前预设:
public function render()
{
$this->selectedState = $this->state['category'];
return view(/* your view */);
}