来自 Livewire sub-form 的数据在请求中丢失

Data from a Livewire sub-form missing in request

在 Laravel 中,我使用 livewire 动态呈现 HTML 表单的一部分。主窗体是常规 Laravel blade 文件,不是 Livewire 组件。但是,提交表单时,livewire sub-form 中的字段值在 $request 变量中丢失。

包含 livewire 组件的 edit.blade.ph 片段。此文件是常规视图 blade 文件,而不是 Livewire 组件.

<div class="row mb-3">
  <textarea id="address" type="text" class="form-control @error('address') is-invalid @enderror" name="address" required autocomplete="address" rows="3">{{ $player->address}}</textarea>
</div>
@livewire('address-input', ['player'=> $player])
<div class="row mb-3">                                    
    <textarea id="description" type="text" class="form-control @error('description') is-invalid @enderror" name="description" required autocomplete="description" rows="3">{{ $player->description}}</textarea>
</div>

Livewire 组件 address-input.blade.php

<div class="row mb-3">
    <label for="region" class="col-md-4 col-form-label text-md-end">{{ __('Region') }}</label>

    <div class="col-md-6">
        <select wire:model="region" class="form-select" aria-label="Region Label">
            <option selected>Select Region</option>
            @foreach($regions as $region)
                <option value="{{$region->id}}">{{$region->region_name}}</option>
            @endforeach
        </select>
    </div>
</div>

<div class="row mb-3">
    <label for="province" class="col-md-4 col-form-label text-md-end">{{ __('Province') }}</label>

    <div class="col-md-6">
        <select wire:model="province" class="form-select" aria-label="Province Label">
            <option selected>Select Province</option>
            @foreach($provinces as $province)
                <option value="{{$province->id}}">{{$province->name}}</option>
            @endforeach
        </select>

    </div>
</div>

<div class="row mb-3">
    <label for="municipality" class="col-md-4 col-form-label text-md-end">{{ __('Municipality') }}</label>

    <div class="col-md-6">
        <select wire:model="municipality" class="form-select" aria-label="Province Label">
            <option selected>Select Municipality</option>
            @foreach($municipalities as $municipality)
                <option value="{{$municipality->id}}">{{$municipality->name}}</option>
            @endforeach
        </select>


    </div>
</div>

<div class="row mb-3">
    <label for="barangay" class="col-md-4 col-form-label text-md-end">{{ __('Barangay') }}</label>

    <div class="col-md-6">
        <select id="barangay_id" class="form-select" aria-label="Barangay Label">
            <option selected>Select Barangay</option>
            @foreach($barangays as $barangay)
                <option value="{{$barangay->id}}">{{$barangay->name}}</option>
            @endforeach
        </select>

    </div>
</div>

提交 edit.blade.php 上的表单时,address-input sub-form 中输入字段的值未包含在请求中,具体而言,[=15 的值=].

dd($request) 的输出。

哦,我真傻。

我忘记在字段元素上包含 name 属性。