M
M
Monitorkin2018-07-21 09:29:47
Yii
Monitorkin, 2018-07-21 09:29:47

How to call controller in Yii2 widget?

Hello, I want to add my own controller to the widget and I don't understand how. Please help.
widget location in folder: app/components/Filter
controller location in folder: app/components/Filter/controllers/FilterController.php (namespace app\components\Filter\controllers;)
desired action in controller: actionSelectVars

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => false,
...
'rules' => [
...
'filter/select-vars' => 'components/Filter/filter/select-vars'
...

I'm trying to call an action at site.ru /filter/select-vars and I get an error - page not found. Where is the mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-07-21
@webinar

How to call a controller in a widget

This is against MCV principles and common sense. Why do this? Here you either need to send ajax or have logic from the action in the form of a helper. Depending on the task. Describe in detail what exactly the widget and action do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question