我正在尝试使用简单树特征来实现父/子关系。
在后端,我使用表单构建器添加了一个关系字段以使父元素可选,即 fields.yaml 文件
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
错误模型不包含 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'
];
}
我在文档中找不到任何信息如何实现关系,以便用户在添加新元素时可以选择父元素。