Octobercms筛选器范围选项未从模型类返回

根据Octobercms documentation,我可以从模型类方法中获取选项。

但是当我尝试过滤列表时,出现了未定义的索引错误。

  

... / modules / backend / Widgets / Filter.php的第417行上的“未定义索引:holiday_type”

我在做什么错?我想通过模型类从方法中获取选项

config_filter.yaml

line+" "+your_annotation

MyModel.php

# ===================================
# Filter Scope Definitions
# ===================================

scopes:
    holiday_type:
        label: Holiday Type
        type: group
        conditions: type in (:filtered)
        options: getHolidayTypesAttribute
qwer123456asdf 回答:Octobercms筛选器范围选项未从模型类返回

您在配置中缺少一件事。 :) modelClass

  

如果您的过滤器类型为group

,则需要指定用于获取选项列表的模型
scopes:
    holiday_type:
        label: Holiday Type
        type: group
        conditions: type in (:filtered)
        options: getHolidayTypesAttribute
        modelClass: Acme\Blog\Models\Category <- you are missing this
  

Acme\Blog\Models\Category替换为your model class,然后尝试执行此操作

如有任何疑问,请发表评论。

本文链接:https://www.f2er.com/3095758.html

大家都在问