'SilverStripe unable to populate multiple member Childs
I have 3 type of users salesman => has many buyers buyer => has many agents agent has none child
so I want to list all the buyers associate with that salesman when viewing salesman and all the agents when viewing buyer in admin
class MemberExtension extends DataExtension
{
private static $has_one = [
'RefSalesman' => Member::class,
'AgentOwner' => Member::class,
];
private static $has_many = [
'Buyers' => Member::class,
'Agents' => Member::class,
];
private static $summary_fields = [
'RefSalesman.Name' => 'Ref Salesman',
'AgentOwner.Name' => 'Agent Owner',
];
This way I am only able to see agents listing under buyers but no buyers when viewing salesman.
Solution 1:[1]
These has-many relations do not know to which has-one they are referring to. Being both the same class, you must explicitely specify the destination relation in dot notation: see the has-many documentation for details.
private static $has_many = [
'Buyers' => Member::class.'.RefSalesman',
'Agents' => Member::class.'.AgentOwner',
];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pervaiz Iqbal |