Iztok
Iztok
FFilament
Created by Iztok on 10/11/2023 in #❓┊help
Form issues dynamically loadin static functions from a class that return an array of form components
So apparently this was never meant to work 🙂 My solution:
Forms\Components\Tabs\Tab::make('Input')
->statePath('input')
->schema([
Forms\Components\Select::make('type')
->options(InputTypes::listOptions())
->required()
->live()
->afterStateUpdated(function ($state) {
if ($state) {
$types = InputTypes::list();
$type_class = $types[$state];
self::$input_type_class = $type_class;
}
}),
... self::getInputSettingsFieldsets(), // instead of the code above
]),



public static function getInputSettingsFieldsets(): array
{
$forms = [];
$input_types = InputTypes::list();

foreach ($input_types as $id => $input_type_class) {
$forms[] = Forms\Components\Fieldset::make('input_settings')
->label(__('Settings'))
->statePath('settings')
->visible(function (Get $get) use ($id) {
if ($get('type') == $id) {
return true;
} else {
return false;
}
})
->schema(function () use ($input_type_class) {
return $input_type_class::settingsForm() ?? [];
});
}

return $forms;
}
Forms\Components\Tabs\Tab::make('Input')
->statePath('input')
->schema([
Forms\Components\Select::make('type')
->options(InputTypes::listOptions())
->required()
->live()
->afterStateUpdated(function ($state) {
if ($state) {
$types = InputTypes::list();
$type_class = $types[$state];
self::$input_type_class = $type_class;
}
}),
... self::getInputSettingsFieldsets(), // instead of the code above
]),



public static function getInputSettingsFieldsets(): array
{
$forms = [];
$input_types = InputTypes::list();

foreach ($input_types as $id => $input_type_class) {
$forms[] = Forms\Components\Fieldset::make('input_settings')
->label(__('Settings'))
->statePath('settings')
->visible(function (Get $get) use ($id) {
if ($get('type') == $id) {
return true;
} else {
return false;
}
})
->schema(function () use ($input_type_class) {
return $input_type_class::settingsForm() ?? [];
});
}

return $forms;
}
2 replies
FFilament
Created by HyMaMa on 10/2/2023 in #❓┊help
The GET method is not supported for route livewire/update
Just to give an example, when changing the model to have SoftDeletes, the 404 error was gone.
20 replies
FFilament
Created by HyMaMa on 10/2/2023 in #❓┊help
The GET method is not supported for route livewire/update
I've found out that if I have a Livewire function that deletes a model this would happen.
20 replies
FFilament
Created by Iztok on 6/27/2023 in #❓┊help
Page with table, query URL
this does the trick! thanks!
8 replies
FFilament
Created by Iztok on 6/27/2023 in #❓┊help
Page with table, query URL
class ViewBucketCustom extends ViewRecord implements Tables\Contracts\HasTable
8 replies
FFilament
Created by Iztok on 6/6/2023 in #❓┊help
SQL error on table bulk action when originally sorting by relationship count
@Dan Harrin thank you!
3 replies
FFilament
Created by Iztok on 4/7/2023 in #❓┊help
Error during upload - no errors in logs, works with smaller files (PHP and Nginx limits lifted)
@Dennis Koch that was it, indeed. Thank you!
3 replies