Have trouble when using Yii2 multilang behavior -


i'm using multilang-behavior

but, when clicking on update button view data, data returning id = 1.

this code in controller:

 public function actionupdate($id) {     $model = post::find()->multilingual()->one();     //$model = post::findone($id);     if ($model->load(yii::$app->request->post()) && $model->save()) {         return $this->redirect(['view', 'id' => $model->id]);     } else {         return $this->render('update', [             'model' => $model,         ]);     } } 

this form view data:

<?php $form = activeform::begin(); ?>  <?= $form->field($model, 'title')->textinput() ?> <?= $form->field($model, 'title_vi')->textinput() ?> <?= $form->field($model, 'title_en')->textinput() ?> <?= $form->field($model, 'created_at')->textinput() ?>  <?= $form->field($model, 'updated_at')->textinput() ?>  <?= $form->field($model, 'enabled')->textinput() ?>  <div class="form-group">     <?= html::submitbutton($model->isnewrecord ? 'create' : 'update', ['class' => $model->isnewrecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div>  <?php activeform::end(); ?> 

this model :

class post extends \yii\db\activerecord {     public static function tablename()     {         return 'post';     }     public function behaviors()     {         return [             'ml' => [                 'class' => multilingualbehavior::classname(),                 'languages' => [                     'vi' => 'vietnammese',                     'en' => 'english',               ],                 //'languagefield' => 'language',                 //'localizedprefix' => '',                 //'requiretranslations' => false',                 //'dynamiclangclass' => true',                 //'langclassname' => postlang::classname(),                  //'defaultlanguage' => 'vi',                 'langforeignkey' => 'post_id',                   'tablename' => "{{%postlang}}",                     'attributes' => [                     'title', 'content',                 ]             ],         ];     }        public static function find()     {     $q = new multilingualquery(get_called_class());         return $q;     }      public static function with()     {         return ;     } } 

and result image

result image


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -