Answer the question
In order to leave comments, you need to log in
Yii2 saving attributes in model?
Hello, the model has an attribute myVar which is stored in Mysql and contains data as a string : '3,4,5,6'. , I can’t figure out why the myVar variable does not change when the model is saved?
Model
...
public function getMyVar(){
return explode(",", $this->myVar);
}
public function setMyVar($value){
$this->myVar = implode(",", $value);
}
...
...
$form->field($model, 'CreditSecurity')->dropDownList(['...'],['multiple' => 'true'])
...
...
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['...']);
}
...
Answer the question
In order to leave comments, you need to log in
Find the method in the model
And add your variable to it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question