十月CMS SimpleTree后端表单
问题描述:
我试图用Simple Tree Trait实现一个父/子关系。十月CMS SimpleTree后端表单
我们已经附上它作为伤心的documentation
在后端我用表单生成器添加relatioship领域做出父元素选择,则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'
];
}
我找不到文档如何落实的关系,以便增加一个新的时,用户可以选择一个父元素中的任何信息。
答
确定,因此该解决方案周围挖后是在后端形式的模型很简单,而不是parent_id
领域应该是parent
如此完整的代码看起来像
fields:
name:
label: 'name'
oc.commentPosition: ''
span: full
required: 1
type: text
image:
label: 'image'
oc.commentPosition: ''
mode: image
span: full
type: mediafinder
parent:
label: 'parent'
oc.commentPosition: ''
nameFrom: name
descriptionFrom: description
span: auto
type: relation