The problem of passing into the database values in uppercase.

Yii 2.0.4

Being a key issue for many, the truth is that I can not solve the problem of passing into the database values in uppercase.

I can force the field to write in capital letters, but this does not keep the database values entered / shown on the form.

The code entered in the form is,

<?= $form->field($model, ‘Name’)->textInput([‘style’ => ‘text-transform: uppercase’, ‘maxlength’ => 254]) ?>

Probably miss define a function for the field to be stored in the database.

Does anyone have an easy solution… Thanks.

u can u this


$str = strtoupper($str);

yes. look here

It seems that found a solution that responds easily to the problem presented.

The code is as follows,

public function rules()

{


    return [


           ...


           [['Name'],'filter','filter'=&gt;'strtoupper'],


           ...


   ];


}

Best regards.