I have created such a situation class
class NewsService extends Model { /** * @param \common\models\News */ private $_newsModel; /** * NewsService constructor. * @param array $config */ public function __construct($config = []) { parent::__construct($config); if(isset($config['id']) && $config['id']) { $this->_newsModel = News::findOne($config['id']); $this->setAttributes($this->_newsModel->getAttributes()); } else { $this->_newsModel = new News(); } } public function rules() { return $this->_newsModel->rules(); } public function attributeLabels() { return $this->_newsModel->attributeLabels(); } In the controller I create this model, but the error takes off that there are no attributes
public function actionCreate() { $model = new NewsService(); if (Yii::$app->request->isPost && $model->validate()) { $model->save(); return $this->redirect(['view', 'id' => $model->id]); } return $this->render('create', ['model' => $model]); } Getting unknown property: common \ models \ service \ NewsService :: title
What could be the problem?