examples:builder:hasmany_relation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
examples:builder:hasmany_relation [2021/04/03 16:27]
pdsci-admin [Step 5: Create the config_relation.yaml controller file]
examples:builder:hasmany_relation [2021/04/11 19:06] (current)
pdsci-admin [Step 4: Announce the relation to the parent model]
Line 84: Line 84:
     public $implement = ['Backend\Behaviors\ListController',     public $implement = ['Backend\Behaviors\ListController',
                          'Backend\Behaviors\FormController',                          'Backend\Behaviors\FormController',
-                         'Backend\Behaviour\RelationController']; // this line adds the relation behaviour+                         'Backend\Behaviors\RelationController']; // this line adds the relation behaviour
          
     public $listConfig = 'config_list.yaml';     public $listConfig = 'config_list.yaml';
Line 102: Line 102:
 </sxh> </sxh>
 \\ \\
-===== Step 4: Announce the relation to the parent model ===== +===== Step 4: Define the relation within the parent model ===== 
-To make the parent model able to work with the relation, the type of the relation, the name of the relation and the child model have to be announced in the parent model. \\+To make the parent model able to work with the relation, the type of the relation, the name of the relation and the child model have to be defined in the parent model. \\
 \\ \\
 {{:examples:builder:hasmany-relation-definition.jpg?direct&960|}} {{:examples:builder:hasmany-relation-definition.jpg?direct&960|}}
Line 115: Line 115:
    ...    ...
        
-   public $hasOne = [+   public $hasMany = [
         'reviews' => ['Pds\Library\Models\Review']         'reviews' => ['Pds\Library\Models\Review']
    ];    ];
Line 193: Line 193:
     label: Reviews     label: Reviews
     view:      view: 
-        form: $/pds/library/models/review/fields.yaml 
         list: $/pds/library/models/review/columns.yaml         list: $/pds/library/models/review/columns.yaml
         toolbarButtons: create|delete         toolbarButtons: create|delete
     manage:     manage:
         form: $/pds/library/models/review/fields.yaml         form: $/pds/library/models/review/fields.yaml
-        list: $/pds/library/models/review/columns.yaml +        
 ... ...
 </sxh> </sxh>