mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
fixed model serializtaion example
This commit is contained in:
@ -71,8 +71,8 @@ public function fields()
|
|||||||
// field name is "email", the corresponding attribute name is "email_address"
|
// field name is "email", the corresponding attribute name is "email_address"
|
||||||
'email' => 'email_address',
|
'email' => 'email_address',
|
||||||
// field name is "name", its value is defined by a PHP callback
|
// field name is "name", its value is defined by a PHP callback
|
||||||
'name' => function () {
|
'name' => function ($model) {
|
||||||
return $this->first_name . ' ' . $this->last_name;
|
return $model->first_name . ' ' . $model->last_name;
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ interface Arrayable
|
|||||||
* 'email',
|
* 'email',
|
||||||
* 'firstName' => 'first_name',
|
* 'firstName' => 'first_name',
|
||||||
* 'lastName' => 'last_name',
|
* 'lastName' => 'last_name',
|
||||||
* 'fullName' => function () {
|
* 'fullName' => function ($model) {
|
||||||
* return $this->first_name . ' ' . $this->last_name;
|
* return $model->first_name . ' ' . $model->last_name;
|
||||||
* },
|
* },
|
||||||
* ];
|
* ];
|
||||||
* ```
|
* ```
|
||||||
|
@ -841,8 +841,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
|
|||||||
* 'email',
|
* 'email',
|
||||||
* 'firstName' => 'first_name',
|
* 'firstName' => 'first_name',
|
||||||
* 'lastName' => 'last_name',
|
* 'lastName' => 'last_name',
|
||||||
* 'fullName' => function () {
|
* 'fullName' => function ($model) {
|
||||||
* return $this->first_name . ' ' . $this->last_name;
|
* return $model->first_name . ' ' . $model->last_name;
|
||||||
* },
|
* },
|
||||||
* ];
|
* ];
|
||||||
* ```
|
* ```
|
||||||
|
Reference in New Issue
Block a user