@@ -115,10 +115,10 @@ If you use database (class 'yii\rbac\DbManager') to save rbac data, execute the
115
115
yii migrate --migrationPath=@yii/rbac/migrations
116
116
```
117
117
118
- Customizing Controller
119
- ----------------------
118
+ Customizing Assignment Controller
119
+ ---------------------------------
120
120
121
- Some controller properties may need to be adjusted to the User model of your app.
121
+ Assignment controller properties may need to be adjusted to the User model of your app.
122
122
To do that, change them via ` controllerMap ` property. For example:
123
123
124
124
``` php
@@ -128,12 +128,35 @@ To do that, change them via `controllerMap` property. For example:
128
128
'controllerMap' => [
129
129
'assignment' => [
130
130
'class' => 'mdm\admin\controllers\AssignmentController',
131
- /* 'userClassName' => 'app\models\User', */ // fully qualified class name of your User model
132
- // Usually you don't need to specify it explicitly, since the module will detect it automatically
133
- 'idField' => 'user_id', // id field of your User model that corresponds to Yii::$app->user->id
134
- 'usernameField' => 'username', // username field of your User model
135
- 'searchClass' => 'app\models\UserSearch' // fully qualified class name of your User model for searching
136
- ]
131
+ /* 'userClassName' => 'app\models\User', */
132
+ 'idField' => 'user_id',
133
+ 'usernameField' => 'username',
134
+ 'fullnameField' => 'profile.full_name',
135
+ 'extraColumns' => [
136
+ [
137
+ 'attribute' => 'full_name',
138
+ 'label' => 'Full Name',
139
+ 'value' => function($model, $key, $index, $column) {
140
+ return $model->profile->full_name;
141
+ },
142
+ ],
143
+ [
144
+ 'attribute' => 'dept_name',
145
+ 'label' => 'Department',
146
+ 'value' => function($model, $key, $index, $column) {
147
+ return $model->profile->dept->name;
148
+ },
149
+ ],
150
+ [
151
+ 'attribute' => 'post_name',
152
+ 'label' => 'Post',
153
+ 'value' => function($model, $key, $index, $column) {
154
+ return $model->profile->post->name;
155
+ },
156
+ ],
157
+ ],
158
+ 'searchClass' => 'app\models\UserSearch'
159
+ ],
137
160
],
138
161
...
139
162
]
@@ -142,6 +165,28 @@ To do that, change them via `controllerMap` property. For example:
142
165
143
166
```
144
167
168
+ - Required properties
169
+ - ** userClassName** Fully qualified class name of your User model
170
+ Usually you don't need to specify it explicitly, since the module will detect it automatically
171
+ - ** idField** ID field of your User model
172
+ The field that corresponds to Yii::$app->user->id.
173
+ The default value is 'id'.
174
+ - ** usernameField** User name field of your User model
175
+ The default value is 'username'.
176
+ - Optional properties
177
+ - ** fullnameField** The field that specifies the full name of the user used in "view" page.
178
+ This can either be a field of the user model or of a related model (e.g. profile model).
179
+ When the field is of a related model, the name should be specified with a dot-separated notation (e.g. 'profile.full_name').
180
+ The default value is null.
181
+ - ** extraColumns** The definition of the extra columns used in the "index" page
182
+ This should be an array of the definitions of the grid view columns.
183
+ You may include the attributes of the related models as you see in the example above.
184
+ The default value is an empty array.
185
+ - ** searchClass** Fully qualified class name of your model for searching the user model
186
+ You have to supply the proper search model in order to enable the filtering and the sorting by the extra columns.
187
+ The default value is null.
188
+
189
+
145
190
Customizing Layout
146
191
------------------
147
192
0 commit comments