amarafath
amarafath
FFilament
Created by amarafath on 12/25/2023 in #❓┊help
Custom Edit Form Input Values Not Populating Input values
I'm encountering an issue with a custom edit form. For some reason, the input values aren't getting filled. Has anyone experienced this before? URL : http://127.0.0.1:8000/admin/leads/1/edit
<?php

namespace App\Filament\Resources\LeadResource\Pages;

use App\Filament\Resources\LeadResource;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;

class EditLead extends Page
{
use InteractsWithForms;

protected static string $resource = LeadResource::class;

protected static string $view = 'filament.resources.lead-resource.pages.edit-lead';

public $data = [];

public function mount(): void
{
$this->form->fill();
static::authorizeResourceAccess();
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('first_name')
->autofocus()
->required()
->maxLength(255)
->placeholder(__('First Name')),
TextInput::make('last_name')
->autofocus()
->required()
->maxLength(255)
->placeholder(__('Last Name')),
])->columns(2)
->statePath('data');
}

protected function getFormActions(): array
{
return [
Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save'),
];
}

}
<?php

namespace App\Filament\Resources\LeadResource\Pages;

use App\Filament\Resources\LeadResource;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Resources\Pages\Page;

class EditLead extends Page
{
use InteractsWithForms;

protected static string $resource = LeadResource::class;

protected static string $view = 'filament.resources.lead-resource.pages.edit-lead';

public $data = [];

public function mount(): void
{
$this->form->fill();
static::authorizeResourceAccess();
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('first_name')
->autofocus()
->required()
->maxLength(255)
->placeholder(__('First Name')),
TextInput::make('last_name')
->autofocus()
->required()
->maxLength(255)
->placeholder(__('Last Name')),
])->columns(2)
->statePath('data');
}

protected function getFormActions(): array
{
return [
Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save'),
];
}

}
<x-filament-panels::page>
<x-filament-panels::form wire:submit="save">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament-panels::form wire:submit="save">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page>
1 replies