我開始十月,我也嘗試創建一個插件,所以也許noob問題,但無法找到一個工作的例子在網上搜索的一些時間和文件是每個單位好,但缺乏「連接點」恕我直言......我想出瞭如何使用SimpleTree(可能不是正確的方式)顯示與id相關的相關名稱。OctoberCMS - 下拉菜單:通過下拉列表選擇名稱保存ID
https://www.screencast.com/t/WDYkfPdMQhttps://www.screencast.com/t/4NDc3HHDs
frmArea.yaml
fields:
id:
label: Número
oc.commentPosition: ''
span: auto
disabled: 1
type: number
area_id:
label: 'Parente de'
oc.commentPosition: ''
emptyOption: 'Sem valor'
span: auto
type: dropdown
nameFrom: area
area:
label: Área
span: full
oc.commentPosition: ''
type: text
Area.php
<?php namespace JML\Gkb\Models;
use Model;
/**
* Model
*/
class Area 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 = 'jml_gkb_areas';
//Relações
public $hasMany = [
'area_id' => 'JML\Gkb\Models\Area'
];
/*
public $belongsTo = [
'area_id' => 'JML\Gkb\Models\Area'
]; */
public function getAreaIdOptions(){
return Area::all()->listsNested('area', 'id');
}
}
如果我沒有選擇任何關係父創造的記錄,它們會產生(在上的那些圖像例如)。如果我嘗試創建選擇一個父母它會得到永久保存...如果我嘗試更新未記錄沒有父母選擇一個父母同樣發生時保存。
在一段時間或至少當我清除緩存我不能創造紀錄沒有父母一段時間後返回鎖定超時......好吧,等待更多一些,我得到超時...遞增ID獲取後經過300秒增加了什麼意思是什麼東西在打破分貝......我懷疑查詢是發送一個字符串在哪裏需要一個數字,但不知道如何實現...
有人可以給一些幫助,找到一些相關的例子或snipets或如何?並有可能達到相同的結果,以列表小部件?
TIA
JL