F
Filamentβ€’10mo 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β€’10mo ago
try shouldSaveRelationshipsWhenDisabled same exists for hidden fields
nowak
nowakOPβ€’10mo 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β€’10mo ago
mmh .. but that's the way
mvenghaus
mvenghausβ€’10mo ago
here i use it ah wrong method πŸ™‚
Solution
mvenghaus
mvenghausβ€’10mo ago
saveRelationshipsWhenHidden
mvenghaus
mvenghausβ€’10mo ago
πŸ™‚
nowak
nowakOPβ€’10mo 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!!
Want results from more Discord servers?
Add your server