Repeater rolls back after save

Hi all, I'm having a strange issue with the repeater field, after saving it rolls back the changes. But when I refresh the page or look at the database the changes are indeed saved. Never seen this before, any ideas? Models: (nothing fancy) Order, OrderItem. Order hasMany OrderItem OrderItem belongs to Order
Forms\Components\Repeater::make('orderItems')
->relationship()
->schema([
Forms\Components\Select::make('product_id')
->relationship(name: 'product', titleAttribute: 'name'),
Forms\Components\TextInput::make('product_amount')
]),
Forms\Components\Repeater::make('orderItems')
->relationship()
->schema([
Forms\Components\Select::make('product_id')
->relationship(name: 'product', titleAttribute: 'name'),
Forms\Components\TextInput::make('product_amount')
]),
No description
Solution:
Ok, just an FYI for the future... So i changed everything to use 'ClientOrder' instead of 'Order' now it works as expected. Not sure what the real problem was, but seems 'Order' can cause a conflict, at least in this scenario 🤷‍♂️...
Jump to solution
6 Replies
icolatsi22
icolatsi223w ago
I have other repeaters in other resources using these models "Product", "ProductVariant" and it works fine. Could it be that the name "Order" cannot be used? I have no idea what is going on...
Dennis Koch
Dennis Koch3w ago
Those fields are fillable?
icolatsi22
icolatsi223w ago
yep, fillable and cast properly as well. Changes are saved to the database correctly, but the old value is returned after hitting save. Like the old state is being used to fill the form, weird... i'm now recreating the models but using different names "ClientOrder" instead of "Order". Maybe using "Order" somehow or somewhere causes an issue, never seen this problem before.
Dennis Koch
Dennis Koch3w ago
Hm. Sounds weird.
Solution
icolatsi22
icolatsi223w ago
Ok, just an FYI for the future... So i changed everything to use 'ClientOrder' instead of 'Order' now it works as expected. Not sure what the real problem was, but seems 'Order' can cause a conflict, at least in this scenario 🤷‍♂️
icolatsi22
icolatsi223w ago
Ok, the problem was not with the naming, you can use "Order", the problem was with an accessor I had added. For some reason it messed up the repeater. So, for next time I need to be careful about accessors on models. Adding this comment for the future.