This forum has moved to a new location and is in read-only mode. Please visit to access the new location.


Hi, I have extended the Static Pages Menu Item by using the below code which adds a media finder option to a menu item. The problem i am having is that once the user select the image to use and hits "Apply", if they return to the menu item the selected image is no longer visible. Any ideas how i might be able to fix this?

I've tried to use "fileupload" as the "type" but I get an error stating that the MenuItem model does not contain a definition for viewBag[menuImage]. Am I able to use "fileupload" as the type and add a definition in the MenuItem Model without directly editing the RainLab\Pages\Classes\MenuItem file?

Currently i have implemented the below in a separate plugin.php file.

Event::listen('backend.form.extendFields', function ($widget) { if ( !$widget->getController() instanceof \RainLab\Pages\Controllers\Index || !$widget->model instanceof \RainLab\Pages\Classes\MenuItem ) { return; } $widget->addTabFields([ 'viewBag[menuImage]' => [ 'tab' => 'Media', 'label' => 'Menu Image', 'commentAbove' => 'Add an image to appear in the menu', 'type' => 'mediafinder', 'mode' => 'image' ] ]); });


So its been 4 weeks and I haven't been able to resolve the issue of my image resetting when you click on the menu item to edit it. The field does not load the previously set image.

Can anyone give me any direction on the best way to allow my client to add an image to a menu item for static and dynamic pages?

Thanks in advance.


hey i want to create a model for save the form but i dont know where to create the model please help me out


Hello @chris15853, maybe this post can help you.


This should be enough to get you started

public function register()
    \Event::listen('backend.form.extendFields', function($widget) {
        if (!$widget->model instanceof \RainLab\Pages\Classes\MenuItem) return;

            'viewBag[class2]' => [
                'label' => 'Secondary Class',
                'tab' => 'rainlab.pages::lang.menuitem.attributes_tab',
                'type' => 'text',

1-5 of 5

You cannot edit posts or make replies: the forum has moved to