Extending an existing formwidget.
0
<?php namespace StudioAzura\Foundation\FormWidgets;
use Backend\FormWidgets\RichEditor;
class RichEditorPlus extends RichEditor
{
protected $defaultAlias = 'rich-editor-plus';
public function init()
{
// set the parent's viewPath so that its partials can be found.
$this->addViewPath('~/modules/backend/formwidgets/richeditor/partials');
parent::init();
}
protected function loadAssets()
{
$savedAssetPath = $this->assetPath;
// set the parent's assetPath so that its assets can be found.
$this->assetPath = '/modules/backend/formwidgets/richeditor/assets';
parent::loadAssets();
// reset our own assetPath
$this->assetPath = $savedAssetPath;
$this->addJs('js/richeditorplus.js');
}
}
And you need to register the new formwidget:
public function registerFormWidgets()
{
return [
FormWidgets\RichEditorPlus::class => 'richeditorplus',
];
}
There are no comments yet
Be the first one to comment