accesses custom delete & validation

This commit is contained in:
akosse 2020-01-27 10:30:26 +03:00
parent c5227f1ee4
commit 75ccbff934
3 changed files with 16 additions and 1 deletions

View File

@ -114,7 +114,11 @@ class AccessesController extends Controller
public function actionCustomDelete($id) public function actionCustomDelete($id)
{ {
$clean_id = str_replace('=', "", stristr($id, '='));
UserCardAccesses::deleteAll(['accesses_id' => $clean_id]);
Accesses::deleteAll(['id' => $clean_id]);
return $this->redirect(['index']);
} }
/** /**

View File

@ -43,7 +43,17 @@ $this->params['breadcrumbs'][] = $this->title;
// return $model->getProjectName(); // return $model->getProjectName();
// }, // },
// ], // ],
['class' => 'yii\grid\ActionColumn'], [
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'buttons' => [
'delete' => function ($data) {
return Html::a("<span class='glyphicon glyphicon-trash' aria-hidden='true'></span>",
['/accesses/accesses/custom-delete', 'id' => $data]);
},
],
],
// ['class' => 'yii\grid\ActionColumn'],
], ],
]); ?> ]); ?>
</div> </div>

View File

@ -40,6 +40,7 @@ class Accesses extends \yii\db\ActiveRecord
[['info'], 'string'], [['info'], 'string'],
[['_projects'], 'safe'], [['_projects'], 'safe'],
[['_users'], 'safe'], [['_users'], 'safe'],
[['name', 'login', 'password', 'link', 'project', 'info'], 'required'],
]; ];
} }