How to make my phpmyadmin (yii2 code) understand foreign languages?




 <?php $form = ActiveForm::begin(); ?>




    <?= $form->field($model, 'description')->textarea(['rows'=>20,'columns'=>100,'maxlength' => 4000]) ?>




    <div class="form-group">

        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Add') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    </div>


    <?php ActiveForm::end(); ?>

this is my view. if i run the code and try to insert a value in the form field ‘description’ in my local language like this (വിനീത്) the value that gets stored is " ????? ". how can i store the value as (വിനീത്) itself and display it in the view.

l i tried like this in my view to make my form to accept other languages




 <div class="synopsis-form col-md-5">

    	<h2><?= Html::encode($this->title) ?></h2>

    

       

        

        <?php $form = ActiveForm::begin( [

    				'method' => 'post',

    				'id'	 =>	'add-fanclub',

    				'accept-charset'=>'UTF-8'

    				] );?>

    

        <?= $form->field($model, 'description')->textarea(['rows'=>10,'maxlength' => 1000]) ?>

    

        <div class="form-group">

            <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

        </div>

    

        <?php ActiveForm::end(); ?>

    

    </div>

but i got a error like this Setting unknown property: yii&#092;widgets&#092;ActiveForm::accept-charset

my main-local.php in common/config (yii2 advanced app)is as follows




 'components' => [

            'db' => [

                'class' => 'yii\db\Connection',

                'dsn' => 'mysql:host=localhost;dbname=user_urshow',

                'username' => 'user',

                'password' => 'user',

                'charset' => 'utf8',

            ],

what am i missing?

Using accept-charset=UTF-8 while the html document is already set as UTF-8 in meta tag or in in the http header, does nothing.

As default form have same encoding as the html document.

Anyway try to pass it as option…


        <?php $form = ActiveForm::begin( [

                                'method' => 'post',

                                'id'     =>     'add-fanclub',

                                'options'=> ['accept-charset'=>'UTF-8']

                                ] );?>



Beside this did you verify that the encoding in the header is utf8?

You can use firebug or any other tool to verify it. But I’m quite sure the answer is yes since yii2 run in utf8 by default.

Did you verify if the data that you received are correct before saving in the database?

Just try a stupid print_r of the form data. If the string is wriìong there is a encoding problem between client and server. Otherwise the problem is between yii application and mysql.

Are the db and table encoding correct?

i got it working. my database collation was latin i changed it to utf8_general_ci