我正在尝试 Livewire 的即时身份验证,这似乎适用于除数组字段之外的其他输入。想知道如何显示数组输入的错误消息。刀片代码
<input type="tel" pattern="[0-9]+" minlength="6" wire:model="contact_phone.{{$index}}"
class="form-control {{ $errors->has('contact_phone.*') ? ' is-invalid' : '' }} " required>
<div>@error('contact_phone') <span class="error text-danger small">{{ $message }}</span> @enderror</div>
验证
public function updated($field)
{
$this->validateOnly($field, [
'contact_phone' => 'required|array|min:1',
'contact_phone.*' => 'required|string|min:3',
]);
}
按照这个文档