How to set default parameters for a widget in Yii2

How to set default parameters for a widget in Yii2

To set default parameters for a widget in Yii2, you need to use the dependency injection container.

Example with DatePicker:

Yii::$container -> set('yiijuiDatePicker', [
	'language' => 'en-US',
]);

The first parameter in set is the class name, and the second is the array of parameters to configure. This way, we can preconfigure our widget properly from the start.

Posts on similar topics

Are you having problems with your Yii2 framework website? Do you need additional functionality?
>Then write to me via the feedback form, and I will try to help you.

Write a comment

Your email address will not be published. Required fields are marked *