十月 CMS:无法创建表单小部件 [英] October CMS : Not able to create a Form Widget
问题描述
我是 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
这篇关于十月 CMS:无法创建表单小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!