十月 CMS:无法创建表单小部件

十月 CMS:无法创建表单小部件

问题描述:

我是 10 月 CMS 的新手,正在学习创建表单小部件.但我收到以下错误:

I'm new to October CMS and learning to create a Form Widget. But I'm getting the following error :

The partial '_field_actorbox.htm' is not found.
/opt/lampp/htdocs/octobermovies/modules/system/traits/ViewMaker.php line 65

我的小部件文件夹名称是formwidgets"我在partials文件夹中的partials文件名是'_widget.htm'我的表单小部件的内容 > Actorbox.php

My widget folder name is 'formwidgets' My partials file name inside partials folder is '_widget.htm' Content of my formwidgets > Actorbox.php

namespace Watchlearn\Movies\FormWidgets;

use Backend\Classes\FormWidgetBase;
use Config;

class ActorBox extends FormWidgetBase
{
    public function widgetDetails()
    {
        return [
            'name' => 'Actorbox',
            'description' => 'Field for adding actors'
        ];
    }

    public function render(){
        return $this->makePartial('widget');
    }

    public function loadAssets()
    {
        $this->addCss('css/select2.css');
        $this->addJs('js/select2.js');
    }
}

我在 plugin.php 中注册小部件的代码

My code to register the widget in plugin.php

public function registerFormWidgets()
    {
        return [
            'Watchlearn\Movies\FormWidgets\ActorBox' => [
                'label' => 'ActorBox Field',
                'code' => 'actorbox'
            ]
        ];
    }

我也尝试查找并查看文档,但找不到任何解决方案.

I tried to find and looked into the documentation also but could not find any solution for this.

Actorbox.php 应该在 formwidgets 路径中.如果正确创建目录结构将像

The Actorbox.php should be in the formwidgets path. If properly created the dir structure would be like

|-- formwidgets
|  
|-- ActorBox.php
|   `-- actorbox
|       |-- assets
|       |   |-- css
|       |   |   |-- actorbox.css
|       |   |   `-- select2.min.css
|       |   `-- js
|       |       |-- actorbox.js
|       |       `-- select2.min.js
|       `-- partials
|           `-- _actorbox.htm