File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public function actions(){
35
35
'class' => SortableAction::className(),
36
36
'activeRecordClassName' => YourActiveRecordClass::className(),
37
37
'orderColumn' => 'name_of_field_storing_ordering',
38
+ 'startPosition' => 1, // optional, default is 0
38
39
],
39
40
// your other actions
40
41
];
Original file line number Diff line number Diff line change 7
7
use yii \base \InvalidConfigException ;
8
8
9
9
class SortableAction extends Action {
10
+
10
11
/**
11
12
* (required) The ActiveRecord Class name
12
13
*
@@ -21,6 +22,13 @@ class SortableAction extends Action {
21
22
*/
22
23
public $ orderColumn ;
23
24
25
+ /**
26
+ * Start index/position default 0
27
+ *
28
+ * @var integer
29
+ */
30
+ public $ startPosition = 0 ;
31
+
24
32
public function init (){
25
33
parent ::init ();
26
34
if (!isset ($ this ->activeRecordClassName )){
@@ -41,7 +49,7 @@ public function run(){
41
49
$ page = $ activeRecordClassName ::findOne ($ item );
42
50
//$page = $activeRecordClassName::find()->where($item);
43
51
$ page ->updateAttributes ([
44
- $ this ->orderColumn => $ i ,
52
+ $ this ->orderColumn => $ i + $ this -> startPosition ,
45
53
]);
46
54
}
47
55
}
You can’t perform that action at this time.
0 commit comments