Answer the question
In order to leave comments, you need to log in
Why doesn't filling the model through model load work in Yii2?
<?php
namespace common\models;
use Yii;
class MyModel extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'mymodel';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'string', 'max' => 70],
[['name'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
];
}
}
$model = new MyModel();
var_dump( $model->load( [ 'name' => 'Vasia' ] ) );
Answer the question
In order to leave comments, you need to log in
1. Если указанное свойство не перечислено в правилах или в поведении.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question