You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a wizard that saves some data on User, and some data on Profile which belongs to a user.
The fields that are related to Profile are put on two different steps of a Wizard inside a Fieldset with relationship method pointing to the HasOneprofile relationship on User model.
It works fine if I only have one fieldset linked to this relationship, but breaks when I have two.
This only happens with SpatieMediaLibraryFileUpload component. Normal fields work fine.
They are on the same relationship, but I've used different names in the make method.
Cloning the relationship works, but this is a nasty hacky fix. Any way we can avoid that?
Expected behavior
SpatieMediaLibraryFileUpload should also just work like other form fields on related models.
Steps to reproduce
Have two related models
Create two fieldsets on the related model inside a form
Put SpatieMediaLibraryFileUpload components in one of the fieldsets
Unfortunately this is not possible, you may only have one component for a particular relationship per form, otherwise they will overwrite each others' data.
@danharrin thanks for your response, but this does work with normal components just fine.
Only medialibrary components have this issue. Doesn't this mean maybe we can work around whatever the issue is for medialibrary components as well?
Just for reference, a kind user on discord suggested I clone the relationship with another name, to which I said this is a nasty hacky fix, and he asked why I think so, and this is my answer:
I think it's nasty because I will have an unnecessary duplication in my model code, which is only there because of a presentation layer decision to separate the form into multiple wizard steps.
Otherwise I would never create two identical relationships with different names.
One sign of this smell is the fact that I have to write a comment above one of the relationship methods to avoid any confusion why we have two methods for the same relationship.
And you can't easily test this, so if someone confident comes in the future and deletes the method, they won't know that they have broken the app. They will just think I was stupid to have such duplication in my code.
Does this make sense?
Package
filament/spatie-laravel-media-library-plugin
Package Version
v3.2.70
Laravel Version
v11.4.0
Livewire Version
No response
PHP Version
8.3.6
Problem description
I have a wizard that saves some data on
User
, and some data onProfile
which belongs to a user.The fields that are related to
Profile
are put on two different steps of aWizard
inside aFieldset
withrelationship
method pointing to theHasOne
profile
relationship onUser
model.It works fine if I only have one fieldset linked to this relationship, but breaks when I have two.
This only happens with
SpatieMediaLibraryFileUpload
component. Normal fields work fine.They are on the same relationship, but I've used different names in the
make
method.Cloning the relationship works, but this is a nasty hacky fix. Any way we can avoid that?
Expected behavior
SpatieMediaLibraryFileUpload
should also just work like other form fields on related models.Steps to reproduce
SpatieMediaLibraryFileUpload
components in one of the fieldsetsReproduction repository
https://github.com/mokhosh/filament-medialibrary-multiple-fieldset-bug
Relevant log output
No response
The text was updated successfully, but these errors were encountered: