N
N
Nikolaymac2017-10-05 11:16:35
Yii
Nikolaymac, 2017-10-05 11:16:35

How to add field to gridview and yii2 model?

There is a Users model in it there are fields day, month, year
Created by CRUD these fields are displayed separately in the gridview. How to create a new field birthday, for example, which will not be in the database, but it must be composed of day, month, year and displayed in the grid

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-10-05
@qonand

make a getter method in the model that will form the date of birth, for example:

public function getBirthDay(){
    return $this->day . '.' . $this->month . '.' . $this->year;
}

and work with it like a normal attribute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question