Reordering repeater items

https://filamentphp.com/docs/3.x/forms/fields/repeater#reordering-items Am I going crazy? Isn't there a way to tell it what column the "order" should save to?
7 Replies
schwartzmj
schwartzmjOP10mo ago
Of course after looking for a while then posting this question, I find it immediately: https://filamentphp.com/docs/3.x/forms/fields/repeater#reordering-items-in-a-relationship
schwartzmj
schwartzmjOP10mo ago
Swear I CMD+F'd and searched multiple times except it doesn't work...?
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255),
Repeater::make('values')
->columnSpanFull()
->columns(2)
->relationship()
->schema([
TextInput::make('value')
->required()
->maxLength(255),
TextInput::make('price_modifier')
->numeric()
])
->orderColumn('sort_order'),
]);
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255),
Repeater::make('values')
->columnSpanFull()
->columns(2)
->relationship()
->schema([
TextInput::make('value')
->required()
->maxLength(255),
TextInput::make('price_modifier')
->numeric()
])
->orderColumn('sort_order'),
]);
awcodes
awcodes10mo ago
Make sure ‘sort_order’ is fillable on the model and that it is included in the relationship query if it’s a pivot.
schwartzmj
schwartzmjOP10mo ago
Just figured this out 🤦‍♂️ Long day Thank you!
awcodes
awcodes10mo ago
Maybe share what the problem was if you care too, it might help people in the future with similar problems. Cheers!
Phil
Phil10mo ago
Saved me hours of debugging 😁
Vincent
Vincent7mo ago
... Same here. Feeling very dumb 😆
Want results from more Discord servers?
Add your server