Error validation and $errors variable

Somehow I don’t have access to validation errors in a nested laravel component inside a livewire view. $errors variable is available in the livewire view but not in a nested laravel component in a livewire view.

livewire/create-form.blade.php (livewire view)

<form ...>
    {{-- The following is ok, $errors variable exists and has errors in it --}}
    {{ $errors }}

    {{-- The following is a laravel component --}}
    <x-text-input name="my-input"/>

components/text-input.blade.php (laravel component used in livewire view)

<input name="{{ $name }}" value=""/>
{{-- The following is not ok, $errors variable doesn't exist in this scope, even though there are validation errors --}}
{{ $errors }}

I’m using livewire v1.0.3

Is it just me or anyone else also having the same problem?

Components don’t have access to each others information, you will have to use dynamic events to get them to talk to each other.

I have the same problem. It’s been previously reported ( and should have been fixed by now but it seems it isn’t yet.

Thanks for the reply @xxdalexx but this is not about component communication. It’s about validation errors not being flashed to the session.

@gjm thank you for the link to the issue, that helped a lot to clarify the issue for me at least.

I’ve opened a PR that fixes this issue:

1 Like

This should be fixed in 1.0.4

@merth did you have any luck with sharing $errors to the child reactively?

hey @ionica, as @lucasromanojf said this should be fixed in 1.0.4, thanks to this PR:

Hi @merth, thanks for replying so quickly. I guess I’m misunderstanding something.

In your example I’ve just noticed your input is a blade component and not a LW component.

I have a Form LW component, inside which there is a child Autocomplete LW component - the Autocomplete contains a standard input element with wire:model set, the Form component handles all the validation but I need it to include the validation for the Autocomplete field as well.

I’ve almost got it all working but not happy with the solution as it feels very hacky with events firing both up and down the chain.

If $errors was available inside the Autocomplete component and reactively updated it would solve my problems.