Problem with Form widget

Hello,

I am having a weired problem with a custom form widget.

The following is my controller

    public $implement = [
        'Backend\Behaviors\ListController',
        'Backend\Behaviors\FormController',
        'Backend\Behaviors\RelationController',
        'Backend\Behaviors\ReorderController'
    ];

    public $listConfig = 'config_list.yaml';
    public $formConfig = 'config_form.yaml';
    public $reorderConfig = 'config_reorder.yaml';
    public $relationConfig = 'config_relation.yaml';


    public function __construct()
    {
        parent::__construct();
        BackendMenu::setContext('My.Portfolio', 'main-menu-portfolio', 'side-menu-portfolio-items');

    }

    public function onShowBlockList(){

        $block = CmsBlock::find(post('form_id'));
        $blockConfigFields = $block->type;
        $config = $this->makeConfig('$/my/cmsblocks/models/cmsblock/slider.yaml');
        $config->model = $block;
        $config->recordOnClick = "$.popup({ handler: 'onUpdateForm', extraData: { record_id: ':id' } });";
        $widget = $this->makeWidget('Backend\Widgets\Form', $config);
        $widget->bindToController();
        $this->vars['widget'] = $widget;
        return $this->makePartial('render_block_list');
    }

but when i click the add repeater field i get the following error

A widget with class name 'formSlider' has not been bound to the controller" on line 585 of D:\work_new\my\modules\backend\classes\Controller.php

the slider.yaml is

fields:
    slider:
        label: Repeater
        prompt: 'Add new item'
        style: default
        span: auto
        type: repeater
        form:
            fields:
                title_slider:
                    label: Text
                    span: auto
                    type: text
                test:
                    label: Text
                    span: auto
                    type: text

Thank you in advance.

Hello, for form widgets to work you have to bind it to controller in beforeDisplay() method of controller and then call it by alias .

in beforeDisplay

$config->alias = 'myCustomForm';

in view

$this->widget->myCustomForm->render();
1 Like