F
FilamentAsuranDex

Component not found after changing a ->live() element

Hello, i have created a full page component which uses a form and a select live field to conditionally show a section, however when i change the select field, i get a "Component not found" error. Here is the error: https://flareapp.io/share/lm2K0O0P Here is the code:
<?php

namespace App\Http\Livewire;

use App\Enum\TransportEnum;
use App\Models\Booking;
use App\Models\RoomDetail;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Livewire\Component;

class TransportDetails extends Component implements HasForms
{
use InteractsWithForms;

public $data = [];
public Booking $booking;

public function mount($id)
{
$this->booking = RoomDetail::find($id)->room->booking;
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Section::make('Transport Details')
->schema([
Select::make('transport_method')
->live()
->options(TransportEnum::class)
->required(),
]),

Section::make('Car Details')
->visible(fn(Get $get) => $get('transport_method') == TransportEnum::DRIVING->value)
->schema([
TextInput::make('car_make_model')
->required(),
TextInput::make('car_numberplate')
->required(),
Select::make('driving_to_campus')
->options([
'yes' => 'Yes',
'no' => 'No',
])
->required(),
Select::make('requires_transport_from_campus')
->options([
'yes' => 'Yes',
'no' => 'No',
])
->required(),
])
]);
}
public function render()
{
return view('livewire.transport_details');
}
}
<?php

namespace App\Http\Livewire;

use App\Enum\TransportEnum;
use App\Models\Booking;
use App\Models\RoomDetail;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Livewire\Component;

class TransportDetails extends Component implements HasForms
{
use InteractsWithForms;

public $data = [];
public Booking $booking;

public function mount($id)
{
$this->booking = RoomDetail::find($id)->room->booking;
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
Section::make('Transport Details')
->schema([
Select::make('transport_method')
->live()
->options(TransportEnum::class)
->required(),
]),

Section::make('Car Details')
->visible(fn(Get $get) => $get('transport_method') == TransportEnum::DRIVING->value)
->schema([
TextInput::make('car_make_model')
->required(),
TextInput::make('car_numberplate')
->required(),
Select::make('driving_to_campus')
->options([
'yes' => 'Yes',
'no' => 'No',
])
->required(),
Select::make('requires_transport_from_campus')
->options([
'yes' => 'Yes',
'no' => 'No',
])
->required(),
])
]);
}
public function render()
{
return view('livewire.transport_details');
}
}
Solution:
Yeah i started out with a hyphen and changed it to an underscore just to see what would happen. Thanks for the tip though Turns out the issue was one of 'laziness'. Livewire 3 seems to look for components at App\Livewire rather than App\Http\Livewire and i'd generated the component using Laravel Idea plugin rather than through the CLI. I recreated the compontent using the CLI and now that its in the "correct" place, it is working fine!...
Flare
Unable to find component: [app.http.livewire.transport-details] - The error occurred at http://localhost/transport-details/9a00a479-ec8c-4b2b-ab6f-46294488a349
Kenneth Sese
Kenneth Sese264d ago
Unsure if this is the issue, but I've always used views with hypens instead of underscores. That doesn't seem to be the issue if the view actually loads for you, but who knows...worth a shot...especially since the error seems to be looking for the view at transport-details
Solution
AsuranDex
AsuranDex264d ago
Yeah i started out with a hyphen and changed it to an underscore just to see what would happen. Thanks for the tip though Turns out the issue was one of 'laziness'. Livewire 3 seems to look for components at App\Livewire rather than App\Http\Livewire and i'd generated the component using Laravel Idea plugin rather than through the CLI. I recreated the compontent using the CLI and now that its in the "correct" place, it is working fine!
Kenneth Sese
Kenneth Sese264d ago
It's interesting that it rendered in the first place...but glad you solved it! 👍
Want results from more Discord servers?
Add your server
More Posts
Customize modal width in simple resource default create and edit actionIs it possible to change the modal width inside of resource's form static method?How to use Livewire Component in Custom Page ?Im Simply tryna use Livewire component in my filament custom page, but i get (second img) "Livewiraction method not working on a standalone ActionI have the following code and the `action` method doesn't get executed. ```php Action::make('addToCaTextColumn placeholder emptyHi! I've got an app I just upgraded from v2 to v3. I've got most of the kinks worked out, but one sCreate action in simple resource as slideoveris there a way to change in the simple resource the create action instead a modal use a slideoverCustom Page with Form BuilderHello Guys, I'm testing the Custom Page and i have a problem with the Repeater Component. It's simpSpatieMediaLibrary Image upload weirdnessI am building a user maintenance form which includes the ability to upload 3 profile images. The imgetTableRecordKey(): Return value must be of type string, nullI suddenly get this error: Filament\Resources\Pages\ListRecords::getTableRecordKey(): Return value mCreating multiple record based on other recordhow can i create a record in other table (credit) when created a record in table (payment) here alsoFileUpload not saving cropped image - v3 BUG?Hello, any file upload experts available? I'm using V3 and using fileUpload for what it is... nothiTextinput value like Placeholder content?In Placeholder::make('name')->content() I can "listen" to the other live() fields of the form and dyhow to eager load in relationship manageri have these models ```php class Company extends Model { public function events(): BelongsToMany