Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Uncaught LogicException: byID can't be called on an UnsavedRelationList


Go to End


826 Views

Avatar
noirlucifer

Community Member, 4 Posts

19 August 2015 at 5:42pm

I am creating a modeladmin menu to manage orders. The 'Order' data object has a has many relationship to 'Package' and the 'Package' has a has_many relationship to 'Product'. I am using gridfield relationeditor in Order and Package to add/link new 'Package' and 'Product'. So basically the process is to click on 'Add Order' then click on 'Add Package' then click on 'Add Product' then fill in the product information. Until this point, everything works fine, but when I filled in all the product fields and click on create an error 'Uncaught LogicException: byID can't be called on an UnsavedRelationList' is thrown. I understand this is because the 'Package' and 'Order' has not been created so it can not associate the products with them.

Of course I can create the Order first, then create the package, then add the 'Product', then everything works fine. However this is not intuitive and it is supposed to add products to packages and then create orders. I don't know is there any way to fulfill what I required, or using gridfields within modeladmin form is not the right solution for this.

Looking forward to any suggestions. Thank you.