Laravel Livewire Property [$name] not found on component

  laravel, laravel-livewire

After creating new Component in Livewire i have this html code into this comonent layout:

<div>
    <form wire:submit.prevent="submit" method="POST">
        @csrf
        <div class="form-group row">
            <label class="col-form-label col-lg-3">
                category name:
                <span class="text-danger">*</span>
            </label>
            <div class="col-lg-12">
                <input wire:model="name" type="text" name="name" class="form-control">
            </div>
        </div>

        <div class="text-right">
            <div class="btn-group" role="group">
                <button type="submit" class="btn btn-primary">create</button>
            </div>
        </div>
    </form>
</div>

and this is my categpory component:

class CategoryComponent extends Component
{
    use WithFileUploads;

    public array $rules = [
        'name' => 'required|min:3|max:50',
    ];

    public function render(): Factory|View|Application
    {
        return view('livewire.backend.pages.categories.category-component');
    }

    public function updated($field)
    {
        try {
            $this->validateOnly($field);
        } catch (ValidationException $e) {
            //...
        }
    }
}

after type 2 character into input which that named name and clicking outside of that, i get this error with Livewire:

LivewireExceptionsPropertyNotFoundException
Property [$name] not found on component: [backend.categories.category-component] 

as you can see i have this input with this name and i’m wondering why i get this error

Source: Laravel

Leave a Reply