Set global parameter for bootstrap5 activeField

Hello,

how i can set a global parameter for the class yii\bootstrap5\ActiveForm? There is in parameter options a css class and i would like change this global for my application.

class ActiveField extends \yii\widgets\ActiveField
{
    public $options = ['class' => ['widget' => 'mb-3']];

I wanted to set the value globally in config.php but that doesn’t work

$config = [
    'components' => [
        'activeField' => [
            'class' => 'yii\widgets\ActiveField',
            'options' => [
                'class' => [
                    'widget'=> 'mb-1',                    
                ],
            ],
        ],

Where is my mistake in thinking? Any ideas?

Thank you very much…

See usage of dependency injection pattern: Key Concepts: Dependency Injection Container | The Definitive Guide to Yii 2.0 | Yii PHP Framework

I haven’t tested it with your widget but it could be the way to go.

thanks for the very good advice.

\Yii::$container->set('yii\bootstrap5\ActiveField', ['options' => ['class'=>'mb-2']]);

i added this in my config/web.php and it works.