Im trying to implement a parent/child relationship using the Simple Tree Trait.
I've attached it as sad in the documentation
In the back end I used the form builder to add a relatioship field to make a parent element selectable, the fields.yaml file
fields:
name:
label: 'name'
oc.commentPosition: ''
span: full
required: 1
type: text
image:
label: 'image'
oc.commentPosition: ''
mode: image
span: full
type: mediafinder
parent_id:
label: Relation
oc.commentPosition: ''
nameFrom: name
descriptionFrom: description
span: auto
type: relation
The error model does not contain a definition of parent_id.
<?php namespace depcore\parts\Models;
use Model;
/**
* Model
*/
class Series extends Model
{
use \October\Rain\Database\Traits\Validation;
use \October\Rain\Database\Traits\SimpleTree;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/*
* Validation
*/
public $rules = [
];
/**
* @var string The database table used by the model.
*/
public $table = 'depcore_parts_series';
/**
* Relations
*/
public $attachOne = [
'image' =>'System\Models\File'
];
}
I could not find any information in the documentation how to implement the relationship so that user can select a parent element when adding a new one.