Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

October CMS : Not able to create a Form Widget

Tags:

php

octobercms

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

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');
    }
}

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.

like image 667
pkdq Avatar asked Jan 05 '23 02:01

pkdq


1 Answers

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
like image 93
Lasithds Avatar answered Jan 07 '23 15:01

Lasithds