Form issues dynamically loadin static functions from a class that return an array of form components

I'm dynamically loading form compnents into schema(). The fields are displayed properly but are not operational (validation, default, saving - all not working).

When I load the static function from the class manually in code, everything is working as expected.

Forms\Components\Fieldset::make('input_settings')
    ->label(__('Settings'))
    ->statePath('settings')
    ->visible(function (Get $get, Component $component) {
        if ($get('type')) {
            return true;
        } else {
            return false;
        }
    })
    ->schema(function (Get $get, Component $component) {
        // this works fine
        return \App\Services\Workflows\InputTypes\FilesUpload::settingsForm() ?? [];

        // this only display the form, but doesn't save the data (even default values don't work)
        if ($type = $get('type')) {
            $types = InputTypes::list();
            $type_class = $types[$type];
            //dd($type_class); // returns "App\Services\Workflows\InputTypes\FilesUpload"
            $form = $type_class::settingsForm();
        } else {
            $form = [];
        }

        return $form;
    })
Was this page helpful?