File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Collection extends Component
34
34
/**
35
35
* @var array of models
36
36
*/
37
- public $ models ;
37
+ public $ models = [] ;
38
38
39
39
/**
40
40
* @var string the name of the form. Sets automatically on [[set()]]
@@ -202,6 +202,11 @@ public function load ($data = null) {
202
202
if (!$ is_bulk ) {
203
203
$ data = [$ data ];
204
204
}
205
+ } else if ($ data ['selection ' ]) {
206
+ foreach ($ data ['selection ' ] as $ id ) {
207
+ $ res [$ id ] = compact ('id ' );
208
+ }
209
+ $ data = $ res ;
205
210
}
206
211
} elseif ($ data instanceof \Closure) {
207
212
$ data = call_user_func ($ data , $ this ->model , $ this ->formName );
@@ -446,6 +451,10 @@ public function getFirstError () {
446
451
return false ;
447
452
}
448
453
454
+ public function count ()
455
+ {
456
+ return is_array ($ this ->models ) ? count ($ this ->models ) : 0 ;
457
+ }
449
458
450
459
public function validate ($ attributes = null ) {
451
460
if (!$ this ->beforeValidate ()) {
You can’t perform that action at this time.
0 commit comments