99use dmstr \modules \prototype \models \search \Less as LessSearch ;
1010use Exception ;
1111use Yii ;
12- use yii \filters \AccessControl ;
1312use yii \helpers \ArrayHelper ;
14- use yii \helpers \Url ;
1513use yii \web \Controller ;
1614use yii \web \HttpException ;
1715
@@ -37,8 +35,6 @@ public function actionIndex()
3735 $ dataProvider = $ searchModel ->search ($ _GET );
3836
3937 Tabs::clearLocalStorage ();
40-
41- Url::remember ();
4238 Yii::$ app ->session ['__crudReturnUrl ' ] = null ;
4339
4440 return $ this ->render (
@@ -59,11 +55,6 @@ public function actionIndex()
5955 */
6056 public function actionView ($ id )
6157 {
62- Yii::$ app ->session ['__crudReturnUrl ' ] = Url::previous ();
63-
64- #Url::remember();
65- #Tabs::rememberActiveState();
66-
6758 return $ this ->render (
6859 'view ' ,
6960 [
@@ -83,7 +74,7 @@ public function actionCreate()
8374
8475 try {
8576 if ($ model ->load ($ _POST ) && $ model ->save ()) {
86- return $ this ->redirect (Url:: previous () );
77+ return $ this ->redirect ([ ' view ' , ' id ' => $ model -> id ] );
8778 } elseif (!Yii::$ app ->request ->isPost ) {
8879 $ model ->load ($ _GET );
8980 }
@@ -108,7 +99,7 @@ public function actionUpdate($id)
10899 if ($ model ->load ($ _POST ) && $ model ->save ()) {
109100 Yii::$ app ->session ->addFlash ('success ' , 'Record has been updated ' );
110101 if (ArrayHelper::getValue ($ _POST , 'subaction ' ) != 'apply ' ) {
111- return $ this ->redirect (Url:: previous () );
102+ return $ this ->redirect ([ ' view ' , ' id ' => $ model -> id ] );
112103 }
113104 }
114105 return $ this ->render (
@@ -130,26 +121,15 @@ public function actionUpdate($id)
130121 public function actionDelete ($ id )
131122 {
132123 try {
133- $ this ->findModel ($ id )->delete ();
124+ if ($ this ->findModel ($ id )->delete ()) {
125+ Yii::$ app ->getSession ()->addFlash ('info ' , "Record # $ id deleted " );
126+ }
134127 } catch (Exception $ e ) {
135128 $ msg = (isset ($ e ->errorInfo [2 ])) ? $ e ->errorInfo [2 ] : $ e ->getMessage ();
136129 Yii::$ app ->getSession ()->addFlash ('error ' , $ msg );
137- return $ this ->redirect (Url::previous ());
138130 }
139131
140- // TODO: improve detection
141- $ isPivot = strstr ('$id ' , ', ' );
142- if ($ isPivot == true ) {
143- return $ this ->redirect (Url::previous ());
144- } elseif (isset (Yii::$ app ->session ['__crudReturnUrl ' ]) && Yii::$ app ->session ['__crudReturnUrl ' ] != '/ ' ) {
145- Url::remember (null );
146- $ url = Yii::$ app ->session ['__crudReturnUrl ' ];
147- Yii::$ app ->session ['__crudReturnUrl ' ] = null ;
148-
149- return $ this ->redirect ($ url );
150- } else {
151- return $ this ->redirect (['index ' ]);
152- }
132+ return $ this ->redirect ('index ' );
153133 }
154134
155135 /**
0 commit comments