2017-09-19 5 views
1

シンプルなツリー特性を使用して親子関係を実装しようとしています。私は親要素の選択、fields.yamlファイルOctober CMS SimpleTreeバックエンドフォーム

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 
を作るためにrelatioshipフィールドを追加するためのフォームビルダを使用し、私は、バックエンドでは documentation

に悲しいとして、それを添付しました

エラーモデルに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' 
    ]; 

} 

私は新しいものを追加するとき、ユーザは親要素を選択することができるような関係を実装する方法をドキュメント内の任意の情報を見つけることができませんでした。

答えて

1

OK、フィールドはparentあるべきparent_id代わりに、ソリューションの周りに掘った後、モデルのためのバックエンドの形で非常に簡単ですので、その完全なコードが

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 
ようになります。
関連する問題