Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
examples:builder:hasone_relation [2021/03/26 23:53] pdsci-admin [Step 3: Extend the parent controller] |
examples:builder:hasone_relation [2021/03/27 07:54] (current) pdsci-admin [Step 5: Create the config_relation.yaml controller file] |
||
|---|---|---|---|
| Line 61: | Line 61: | ||
| <WRAP clear /> | <WRAP clear /> | ||
| \\ | \\ | ||
| + | \\ | ||
| + | Here is the complete code to copy, the highlighted rows are the lines probably to add, if the controller was already created. Please remember // | ||
| + | \\ | ||
| + | <sxh php; highlight: [10,18]> | ||
| + | <?php namespace Pds\Library\Controllers; | ||
| + | |||
| + | use Backend\Classes\Controller; | ||
| + | use BackendMenu; | ||
| + | |||
| + | class Books extends Controller | ||
| + | { | ||
| + | public $implement = [' | ||
| + | ' | ||
| + | ' | ||
| + | | ||
| + | public $listConfig = ' | ||
| + | public $formConfig = ' | ||
| + | | ||
| + | //add configuration of relation for Books | ||
| + | // this file has to be created then manually inside the | ||
| + | // [namespace]\controllers\[controllername] folder | ||
| + | public $relationConfig = ' | ||
| + | |||
| + | public function __construct() | ||
| + | { | ||
| + | parent:: | ||
| + | BackendMenu:: | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | \\ | ||
| + | ===== Step 3: Extend the parent controller ===== | ||
| + | As for all relations the controller of the parent table has to be extendend by a few lines to add the relation behaviour. This simlpy is to tell OctoberCMS and the parent table how deal with relations.\\ | ||
| + | In case this step has been done already for another relation, skip it because this is required only once!\\ | ||
| + | |||
| + | {{: | ||
| + | <WRAP clear /> | ||
| \\ | \\ | ||
| Here is the complete code to copy, the highlighted rows are the lines probably to add, if the controller was already created. Please remember // | Here is the complete code to copy, the highlighted rows are the lines probably to add, if the controller was already created. Please remember // | ||
| Line 165: | Line 202: | ||
| <sxh yaml> | <sxh yaml> | ||
| + | ... | ||
| + | |||
| description: | description: | ||
| label: Description | label: Description | ||
| Line 173: | Line 212: | ||
| form: $/ | form: $/ | ||
| list: $/ | list: $/ | ||
| + | |||
| + | ... | ||
| </ | </ | ||