how to fill form at simple page
tried to use $this->form->fill([]) but cant fill the form
21 Replies
Post your code
cant share my full code, but the main idea is something like
tried this with extends CreateRecord the form fill can work by using this
but I need to use simplepage because the form need to be for guest(non login user)
what is $formContent?
If it is array this not going to work
It is an array inside an array
oh wrong copy paste, it's should be like
Check this, it should work https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#adding-the-form
ah found out the problem, need to declare the fields variable
thought no need anymore in v3
Can you please explain how you solved the issue?
at my case, I need to declare the field variable
ex.
for TextInput::make('name')
I am struggling with this for the last 3 days.
Here is my code :
<?php
namespace App\Livewire;
use Carbon\Carbon;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Illuminate\Support\Str;
use Livewire\Component;
class RegisterUserAndCarForm extends Component implements HasForms
{
use InteractsWithForms;
public ?array $data = [];
public ?string $title = null;
public function mount(): void
{
$this->form->fill([
'title' => 'text',
]);
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')
->required(),
])
->statePath('data');
}
public function render()
{
return view('livewire.register-user-and-car-form');
}
}
@Stevee do you see anything strange here?cant find anything strange
Remove
->statePath('data')
this and try again..This did not helped.
Here is the blade file also.
<div>
<form wire:submit="create">
{{ $this->form }}
<button type="submit">
Submit
</button>
</form>
<x-filament-actions::modals />
</div>
@Vp @Stevee if you run the code .. does it work for you?Are you using the Form Builder outside the admin panel?
Yes. I use it in a Livewire component @Leandro Ferreira
Working fine
My code
do you have components/layouts/app.blade file?
mine has this content:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $title ?? 'Page Title' }}</title>
@vite(['resources/css/app.scss', 'resources/js/app.js'])
</head>
<body>
{{ $slot }}
@livewireScriptConfig
</body>
</html>
I wonder if the issue is connected to an older version of the JS filesNo i dont have layouts for livewire, i just include it on my sidebar.. i'll try to check on full livewire if you still have this error on 2moro, rn i am out of work dnt have computer
You’re missing the filament styles and scripts directives in your layout. https://filamentphp.com/docs/3.x/forms/installation#configuring-your-layout
Yes. You are right. Thank you!
How can i include the CSS for the grid system in this custom layout?
Use the grid blade component.