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(){
3535 'class' => SortableAction::className(),
3636 'activeRecordClassName' => YourActiveRecordClass::className(),
3737 'orderColumn' => 'name_of_field_storing_ordering',
38+ 'startPosition' => 1, // optional, default is 0
3839 ],
3940 // your other actions
4041 ];
Original file line number Diff line number Diff line change 77use yii \base \InvalidConfigException ;
88
99class SortableAction extends Action {
10+
1011 /**
1112 * (required) The ActiveRecord Class name
1213 *
@@ -21,6 +22,13 @@ class SortableAction extends Action {
2122 */
2223 public $ orderColumn ;
2324
25+ /**
26+ * Start index/position default 0
27+ *
28+ * @var integer
29+ */
30+ public $ startPosition = 0 ;
31+
2432 public function init (){
2533 parent ::init ();
2634 if (!isset ($ this ->activeRecordClassName )){
@@ -41,7 +49,7 @@ public function run(){
4149 $ page = $ activeRecordClassName ::findOne ($ item );
4250 //$page = $activeRecordClassName::find()->where($item);
4351 $ page ->updateAttributes ([
44- $ this ->orderColumn => $ i ,
52+ $ this ->orderColumn => $ i + $ this -> startPosition ,
4553 ]);
4654 }
4755 }
You can’t perform that action at this time.
0 commit comments