【问题标题】:Does not contain a definition for 'file_src' October CMS不包含“file_src”十月 CMS 的定义
【发布时间】:2018-01-26 21:18:56
【问题描述】:

我目前在十月 CMS 插件开发工作,我遇到了文件上传问题。我将fileupload 类型设置为file_src。当我转到资源时,它会显示如下错误:

model/resource
    fields:
        name:
            label: Name
            type: text
            required: true
        file_src:
            label: Upload
            type: fileupload
        grade_id:
            label: Grade
            type: dropdown
            emptyOption: Select
            showSearch: true
        subject_id:
            label: Subject
            type: dropdown
            emptyOption: Select
            showSearch: true
        type_id:
            label: Type
            type: dropdown
            emptyOption: Select
            showSearch: true

我该如何解决这个错误?

【问题讨论】:

    标签: octobercms-plugins


    【解决方案1】:

    我修好了!我们必须在模型上使用 $attachOne 或 $attachMany 关系

    我在模型的 Resource.php 中添加了以下代码

    public $attachOne = [
        'file_src' => 'System\Models\File'
    ];
    

    这就是它现在的工作!

    【讨论】:

      【解决方案2】:

      定义当前模块选中的控件是一个文件。意味着你的 当前选择的控件是一个文件,你没有在你的 模块那个时候后端已经糊涂了。

      解决方案:

      public $attachOne = [
              'profile_pic' => \System\Models\File::class
          ];
      

      【讨论】:

        猜你喜欢
        • 2017-07-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-18
        • 2018-04-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多