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.