On laravel 11 /livewire 3 site I use volt classes to render 1 element block, like in
resources/views/livewire/common/controls/input_text.blade.php I have code :
<?php
use Livewire\Volt\Component;
use Livewire\Attributes\Modelable;
new class extends Component {
#[Modelable]
public $form;
public string $formattedValue = '';
public string $fieldName = '';
public string $label = '';
public ?string $placeholder = '';
public ?int $maxlength = 0;
};
?>
<div class="editor_field_block_wrapper d2">
<div class="editor_field_block_device_splitter">
<div class="w-4/12 pb-0 pl-2 md:pt-3 ">
<label for="{{ $fieldName }}" class="editor_field_block_device_label">
{{ !empty($label) ? $label: \Str::ucfirst(\Str::replace('_', ' ', $fieldName)) }}:
</label>
</div>
<div class="p-2 w-full">
<input id="{{ $fieldName }}" name="{{ $fieldName }}" type="text"
class="editor_form_input"
@if(!empty($maxlength)) maxlength="{{ $maxlength }}" @endif
wire:model="form.{{ $fieldName }}"
autocomplete="off"
@if(!empty($placeholder)) placeholder="{{ $placeholder }}" @endif
/>
@error('form.' . $fieldName)
<span class="error_text">{{$message}}</span>
@enderror
</div>
</div>
</div>
and I use this volt class in blade fil as :
<livewire:common.controls.input_text fieldName="name" wire:model="form" :maxlength="50" key="nameInputText" />
I use form object for this editor and I pass it to Volt class and use #[Modelable] attribute.
But when submitting the form validation errors are raised the block :
@error('form.' . $fieldName)
<span class="error_text">{{$message}}</span>
@enderror
Does not not work. Checking $errors->all()) and putting it in parent blade file all errors are shown ok.
Bit in volt class these errors are not shown. Any idea how to tie $errors->all()) to my volt class ?
"laravel/framework": "^11.9",
"livewire/livewire": "^3.5",
"livewire/volt": "^1.6",
Thanks in advance!