Answer the question
In order to leave comments, you need to log in
Yii2, Can I add my own property to an ActiveRecord object?
More precisely, not to the object itself, but to the attributes of the collection of this object. Those. along the way, I calculate additional parameters from the record from the database, and I would like to add them to AR, so that later I can display them through standard widgets, with sorting. I hope I explained clearly.
Answer the question
In order to leave comments, you need to log in
Clearly explained.
Just add your properties inside the class.
For example
<?php
//Не забудьте о неймспейсах
//...
class User extends ActiveRecord
{
public $test;
//остальной код...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question