Media Finder widget fails in modal forms

Hi Everyone!

I try to add custom fields to a modal form in the menu manager (static pages). There is an issue with mediafinder field. This is a piece of code:

s0

When I click ‘Main menu’ it looks like that:

It should be a part of the modal form but it isn’t. The custom fields cover list of items and subitems. I can’t even add a new subitem.
Did you have a similar problem?

PS. I use OctoberCMS v2

Hi @talkenberg, welcome to the forum.

Please include the complete code that you are using so that we may test it. Also please avoid posting images of text, as per the foum rules:

  • Post text and not images - Do not include screenshots of code, logs, configuration or other text files. Always copy and paste the text into your post and use code blocks (use the ``` characters on new lines before and after the text).

Best!

I’m sorry for the code screenshot ;). The code is in one of plugin registration file (Plugin.php):

    public function boot()
    {
        Event::listen('cms.page.display', function ($controller, $url, $page, $result) {
            $headers = [
                'Cache-Control' => 'max-age=2592000, public',
            ];
            return ResponseFacade::make($result, $controller->getStatusCode(), $headers);
        });

        App::error(
            function (ModelNotFoundException $exception) {
                return App::make(Controller::class)
                    ->setStatusCode(Response::HTTP_NOT_FOUND)
                    ->run('/404');
            }
        );

        Event::listen(
            'pages.menuitem.listTypes',
            function () {
                return [
                    'section' => 'Section',
                ];
            }
        );

        Event::listen(
            'backend.form.extendFields',
            function (Form $widget) {
                if (!$widget->getController() instanceof Index || (!$widget->model instanceof StaticBackendPage && !$widget->model instanceof MenuItem)) {
                    return;
                }

                $widget->removeTab('rainlab.pages::lang.menuitem.display_tab');
                $widget->removeTab('rainlab.pages::lang.menuitem.attributes_tab');

                if ($widget->model instanceof StaticBackendPage) {

                    $widget->addTabFields(
                        [
                            'viewBag[noIndex]' => [
                                'tab' => 'cms::lang.editor.meta',
                                'label' => 'Add page to indexation?',
                                'type' => 'switch',
                                'options' => ['Yes', 'No'],
                            ],
                        ]
                    );
                }
               
                if ($widget->model instanceof MenuItem) {
                    $widget->addTabFields(
                        [
                            'viewBag[cssIcon]' => [
                                'tab' => 'Attributes',
                                'label' => 'Icon',
                                'type' => 'mediafinder',
                                'trigger' => [
                                    'action' => 'show',
                                    'field' => 'type',
                                    'condition' => 'value[url]'
                                ],
                            ],
                            'viewBag[sectionType]' => [
                                'tab' => 'Attributes',
                                'label' => 'Section type',
                                'comment' => 'Please select a section type',
                                'type' => 'dropdown',
                                'default' => 'other',
                                'options' => [
                                    'other' => 'Other',
                                    'tiles' => 'Highlighted Tiles',
                                    'icons' => 'With Icons',
                                ],
                                'trigger' => [
                                    'action' => 'show',
                                    'field' => 'type',
                                    'condition' => 'value[section]'
                                ],
                            ],
                            'viewBag[item_description]' => [
                                'tab' => 'Attributes',
                                'label' => 'Description',
                                'comment' => 'Enter a description (only appears when item is in highlighted section)',
                                'trigger' => [
                                    'action' => 'hide',
                                    'field' => 'type',
                                    'condition' => 'value[section] || value[url]'
                                ]
                            ],
                            'viewBag[icon]' => [
                                'tab' => 'Attributes',
                                'label' => 'Icon',
                                'type' => 'text',
                                'default' => 'ico/plane.svg',
                                'trigger' => [
                                    'action' => 'hide',
                                    'field' => 'type',
                                    'condition' => 'value[section] || value[url]',
                                ]
                            ]

                        ]
                    );
                }
;
            }
        );
    }

If I remove the condition if ($widget->model instanceof MenuItem) { and so on, the modal form appears afer clicking Add subitem.