-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Environment
- Laravel Version: 11.28
- Nova Version: 5.7
- PHP Version: 8.3
- Database Driver & Version: MySQL 8.0
Description
When using uniqueField in combination with asHasMany on a Repeater field, sorting repeatable items does not function as expected.
Because uniqueField prevents IDs from being regenerated, Nova is unable to determine the correct sort order.
At the moment, we are using a temporary workaround by adding a hidden sort field within our BaseBlock model, which we manually populate using the fillUsing method.
Steps to Reproduce
- Define a
Repeaterfield as follows:
Repeater::make('Blocks')
->asHasMany()
->uniqueField('id')
->repeatables([
Repeaters\TextBlock::make(),
Repeaters\ImageBlock::make(),
]),
- Attempt to reorder the repeatable items in the Nova interface.
- Observe that the order does not persist as expected due to the use of
uniqueField.
Expected Behavior
The repeater items should remain sortable and persist their order even when using uniqueField in combination with asHasMany.
Actual Behavior
Sorting is not functional, as the uniqueField prevents Nova from updating or tracking the order of repeatable items.
Workaround
We currently work around this limitation by including a hidden sort field in our base model and manually setting its value via fillUsing.