It looks like you're trying to dynamically populate a form in a Filament action slide-over, but the default values aren't appearing in the form fields. This issue often arises from how the form schema is being set up or how the data is being passed to the form.
Here are a few things to check and try:
-
Ensure the Record is Passed Correctly: Make sure that the record is being passed correctly to the
getFormSchemamethod. You seem to be doing this correctly, but double-check that the record is notnullwhen you callgetFormSchema. -
Check the Form Schema: Ensure that the form schema is correctly using the record to set default values. You commented out the default value for
object_key. Uncomment it and ensure it's correctly accessing the record's properties.public static function getFormSchema(?ArchObject $record = null): array { return [ Forms\Components\TextInput::make('object_key') ->default($record ? $record->object_key : 'default_value') ->required(), Forms\Components\TextInput::make('hcat_reference') ->default($record ? $record->hcat_reference : 'default_value') ->required(), // Add other fields as necessary ]; } -
Check the Action Setup: Ensure that the
mountUsingmethod is correctly setting the form schema. You might want to log orddthe$recordinside themountUsingclosure to ensure it's being passed correctly.public function slideAction(): Action { return Action::make('slide') ->slideOver() ->mountUsing(function (Action $action, $record) { // Debugging: Check if the record is being passed correctly // dd($record); $action->form( ArchObjectResource::getFormSchema($record) ); }) ->action(function (array $data, ArchObject $record) { // Handle form submission here }); } -
Check for JavaScript Errors: Sometimes, JavaScript errors can prevent the form from rendering correctly. Open your browser's developer tools and check the console for any errors.
-
Clear Cache: If you've made changes and they don't seem to be taking effect, try clearing your application's cache. Run the following commands:
php artisan cache:clear php artisan config:clear php artisan view:clear -
Verify Filament Version: Ensure that you are using a compatible version of Filament with your code. Sometimes, breaking changes in newer versions can cause unexpected behavior.
By following these steps, you should be able to identify why the form fields aren't displaying the expected data. If the issue persists, consider providing more context or checking the Filament documentation for any updates or changes that might affect your implementation.