set yii\widgets\MaskedInput field readonly

Hi Everyone,

I try to set a yii\widgets\MaskedInput Field in activeForm to be readonly, but still no luck.




 <?= $form->field($model, 'netto')->widget(\yii\widgets\MaskedInput::className(),

            [                       

                'clientOptions' => [

                    'alias' => 'numeric',

                    'groupSeparator' => ',',

                    'digits' => 0,

                    'autoGroup' => true,

                    'removeMaskOnSubmit' => true,

                    'rightAlign' => false,


                ]

            ]) ?>



Please advice. Thanks before

Hi,

I have found the answer,




           <?= $form->field($model, 'netto')->widget(\yii\widgets\MaskedInput::className(),

            [       

                'options' => ['readonly' => true],

                'clientOptions' => [

                    'alias' => 'numeric',

                    'groupSeparator' => ',',

                    'digits' => 0,

                    'autoGroup' => true,

                    'removeMaskOnSubmit' => true,

                    'rightAlign' => false,

                ]

            ]) ?>



But it changes the layout. My link

Why?

Please advice. thanks.

I found the solution, just override the option class again




'options' => [

    'readonly' => true, 

    'class' => 'form-control',

],