F
Filamentβ€’4mo ago
nowak

Disabled Select field inside Repeater item not storing data

I have this Select field insider my Repeater item:
Forms\Components\Select::make('attributeValues')
->label(false)
->disabled()
->relationship('attributeValues', 'value')
->hidden(fn (Get $get) => ProductType::find($get('../../product_type_id'))?->name == 'Simple')
Forms\Components\Select::make('attributeValues')
->label(false)
->disabled()
->relationship('attributeValues', 'value')
->hidden(fn (Get $get) => ProductType::find($get('../../product_type_id'))?->name == 'Simple')
Which I have disabled because it is purely there to store relationship data in a pivot table. When I disable the Select field, the relationship data is not stored in the pivot tabel, but if I remove ->disabled() the data is saved as expected. Is there a way to disable or hide a Select field like this, while still storing the data in the pivot table?
Solution:
saveRelationshipsWhenHidden
Jump to solution
8 Replies
mvenghaus
mvenghausβ€’4mo ago
try shouldSaveRelationshipsWhenDisabled same exists for hidden fields
nowak
nowakβ€’4mo ago
How exactly should this be used? This doesn't seem to work:
Forms\Components\Select::make('attributeValues')
->label(false)
->relationship('attributeValues', 'value')
->hidden()
->shouldSaveRelationshipsWhenHidden(),
Forms\Components\Select::make('attributeValues')
->label(false)
->relationship('attributeValues', 'value')
->hidden()
->shouldSaveRelationshipsWhenHidden(),
mvenghaus
mvenghausβ€’4mo ago
mmh .. but that's the way
mvenghaus
mvenghausβ€’4mo ago
here i use it ah wrong method πŸ™‚
Solution
mvenghaus
mvenghausβ€’4mo ago
saveRelationshipsWhenHidden
mvenghaus
mvenghausβ€’4mo ago
πŸ™‚
nowak
nowakβ€’4mo ago
This should be in the documentation right about here somewhere: https://filamentphp.com/docs/3.x/forms/fields/select#integrating-with-an-eloquent-relationship Would have saved me 24 hours of tinkering. Thank you so much!!