kosala manojeewa
kosala manojeewa

Reputation: 329

silverstripe 4 has_many relationship giving errors

getting this error;

[Emergency] Uncaught InvalidArgumentException: has_many relation abc\def\ghi\Customer.OrderRegistrants references class Order which doesn't exist

 private static $has_many = [
        'OrderRegistrants'      => 'Order.Registrant'
]

Upvotes: 3

Views: 382

Answers (1)

scrowler
scrowler

Reputation: 24406

Assuming Order has a namespace, you're not referencing it correctly. Try this:

private static $has_many = [
    'OrderRegistrants'      => Order::class . '.Registrant',
];

This will ensure that any imported (via use My\Package\Order; for example) namespaces for the Order class will be honoured. The way you've got it won't take any namespaces into account.

Upvotes: 2

Related Questions