3

I'm new to Yii and try to write a widget. It is a complex one and include an "Actions", that should render a View inside this widget.

I used to $this->renderPartial(); inside the Action, but it throw error.

My widget class shortened constuction is

class CCProductFilters extends CWidget {
...
public static function actions() {
        return array(
            'CutShapeSelected' => 'application.components.rigthSidebar.widget.actions.contactFormSubmitted'          
        );
    }
...

}
Viktor P
  • 43
  • 1
  • 6

1 Answers1

3

Regarding your question you did not specify neither the structure of your widget nor the path to the file you're attempting to access, but I can assume that your view file can be found under the inner component folder:

If your structure is looks like this:

-components
 | - rigthSidebar
     | - widget
         | - actions
             | - contactFormSubmitted.php
             | - ...
         | - views 
             | - YOUR_VIEW_FILE.php
             | - ...
         | - CCProductFilters.php

then you'd use the following code to access a view file right from the action file

$this->controller->renderPartial('application.components.rigthSidebar.widget.views.YOUR_VIEW_FILE.php', array(), false, true);

Please note, that you can't just $this->renderPartial(); inside widget Action without accessing to the controller. Hope it helps, cheers!

Ignat B.
  • 665
  • 1
  • 10
  • 20