FillForms not working on a custom page with multiple forms.
I got a custom page where i use multiple forms.
in the mount function i add a fillforms method.
Then i try to fill it but the toggle always stays false i dont know what im missing
public function mount(): void
{
if (!isAssetManager() && !isManager()) {
abort(404);
}
//Get the user
$this->user = Filament::auth()->user();
$this->profileData = [
// 'id' => $user->id,
'Naam' => $this->user->name,
'Email' => $this->user->email,
'Telefoonnummer' => $this->user->phone_number,
// Add other properties as needed
];
$this->fillForms();
public function mount(): void
{
if (!isAssetManager() && !isManager()) {
abort(404);
}
//Get the user
$this->user = Filament::auth()->user();
$this->profileData = [
// 'id' => $user->id,
'Naam' => $this->user->name,
'Email' => $this->user->email,
'Telefoonnummer' => $this->user->phone_number,
// Add other properties as needed
];
$this->fillForms();
protected function fillForms(): void
{
$this->getAccountFormSchema->fill();
$this->getDashboardFormSchema->fill();
$this->getConnectivityFormSchema->fill(['mileage_request_service' => true]);
}
protected function getForms(): array
{
return [
'getAccountFormSchema',
'getDashboardFormSchema',
'getConnectivityFormSchema',
];
}
protected function getConnectivityFormSchema(Form $form): Form
{
return $form
->schema([
Toggle::make('mileage_request_service')
->label('Kilometerstand ophalen doormiddel van online service')
->reactive(),
]);
}
protected function fillForms(): void
{
$this->getAccountFormSchema->fill();
$this->getDashboardFormSchema->fill();
$this->getConnectivityFormSchema->fill(['mileage_request_service' => true]);
}
protected function getForms(): array
{
return [
'getAccountFormSchema',
'getDashboardFormSchema',
'getConnectivityFormSchema',
];
}
protected function getConnectivityFormSchema(Form $form): Form
{
return $form
->schema([
Toggle::make('mileage_request_service')
->label('Kilometerstand ophalen doormiddel van online service')
->reactive(),
]);
}
1 Reply
Solution
Fixed the problem