1 回答

TA貢獻2037條經驗 獲得超6個贊
由于內部代碼,這是不可能的。所以我建議不要嘗試解決它。它無法解決:)嘗試替代方案
為什么 ??
因為 from code taglist 的設計方式使其可以與TAGS
.?allow to create new tags
如果存在no selected tag
并且標簽存在,那么它將到attache
給定的記錄。這一切都將與real attributes
.
所以它的設計不適合使用虛擬屬性。
有關更多詳細信息,這是生成標簽的代碼
public function getFieldOptions()
{
? ? $options = $this->formField->options();
? ? if (!$options && $this->mode === static::MODE_RELATION) {
? ? ? ? $options = RelationBase::noConstraints(function () {
? ? ? ? ? ? $query = $this->getRelationObject()->newQuery();
? ? ? ? ? ? // Even though "no constraints" is applied, belongsToMany constrains the query
? ? ? ? ? ? // by joining its pivot table. Remove all joins from the query.
? ? ? ? ? ? $query->getQuery()->getQuery()->joins = [];
? ? ? ? ? ? return $query->lists($this->nameFrom); // <==== LOOK HERE
? ? ? ? });
? ? }
? ? return $options;
}
您可以看到這nameFrom
是直接傳遞給查詢的,這樣query/sql
做not know about our virtual field
是行不通的。
或者,您可以使用
RelationController Behaviors
如有疑問請評論。
- 1 回答
- 0 關注
- 150 瀏覽
添加回答
舉報