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
schwartzmjOP11mo 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
schwartzmjOP11mo 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
awcodes11mo 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
schwartzmjOP11mo ago
Just figured this out 🤦‍♂️ Long day Thank you!
awcodes
awcodes11mo ago
Maybe share what the problem was if you care too, it might help people in the future with similar problems. Cheers!
Phil
Phil11mo ago
Saved me hours of debugging 😁
Vincent
Vincent9mo ago
... Same here. Feeling very dumb 😆

Did you find this page helpful?