wireui / wireui

TallStack UI components
https://v1.wireui.dev
MIT License
1.37k stars 166 forks source link

Undefined variable $_instance #20

Closed aliqasemzadeh closed 2 years ago

aliqasemzadeh commented 2 years ago

After I add currency input I get:

ErrorException
Undefined variable $_instance (View: C:\xampp\htdocs\noyan-io\resources\views\vendor\wireui\components\inputs\currency.blade.php)

currency input code:

                        <x-inputs.currency
                            label="Currency"
                            placeholder="Currency"
                            icon="currency-dollar"
                            thousands="."
                            decimal=","
                            precision="4"
                            wire:model="currency"
                        />
PH7-Jack commented 2 years ago

Is this component inside a livewire component?

aliqasemzadeh commented 2 years ago

No It is not in livewire.

PH7-Jack commented 2 years ago

This component needs a livewire instance to work, because are using @entangle directive

aliqasemzadeh commented 2 years ago

I try to use it in livewire component but I have problem yet.

PH7-Jack commented 2 years ago

Same error? What's your livewire version? Can show more details?

aliqasemzadeh commented 2 years ago

livewire component:

<?php

namespace App\Http\Livewire\Panel;

use Livewire\Component;

class Panel extends Component
{
    public $currency;

    public function render()
    {
        return view('livewire.panel');
    }
}

And view:

<x-panel-layout>
    <x-inputs.currency
        label="Currency"
        placeholder="Currency"
        thousands="."
        decimal=","
        precision="4"
        wire:model="currency"
    />
</x-panel-layout>
PH7-Jack commented 2 years ago

You can test this code?

<div x-data="{ name: @entangle('name') }">
     <span x-text="name"></span>
</div>
<php
...
public $name='testing';
...
aliqasemzadeh commented 2 years ago

@PH7-Jack Yet I get that error. Please guide me to fix it.

PH7-Jack commented 2 years ago

@alighasemzadeh what's your livewire and laravel version?

aliqasemzadeh commented 2 years ago

Laravel 8.74.0 Livewire 2.5.1 @PH7-Jack

PH7-Jack commented 2 years ago

Can check if don't has any component that uses @entangle directive outside a livewire component?

aliqasemzadeh commented 2 years ago

@PH7-Jack How can I testit?

PH7-Jack commented 2 years ago

@alighasemzadeh you need to check in your base layout, check if has any blade component using @entangle

Check the route: if the route bind directly a livewire component https://laravel-livewire.com/docs/2.x/rendering-components#page-components Check the blade app layout

You need to find a wrong importation of wireui component (that using @entangle) or any other component or code using this directive

You can try too clear view php artisan view:clear

aliqasemzadeh commented 2 years ago

@PH7-Jack
Fixed. Just try to use full page component.