Answer the question
In order to leave comments, you need to log in
How to display a modal window on a condition?
Hello,
I have a GridView which has a column with a status, it is editable. How to make a modal window appear when a certain status is selected, for example, I select the "canceled" status, and immediately pop up with options for what reason and the confirm button ...
[
'class'=>'kartik\grid\EditableColumn',
'attribute' => 'State',
'headerOptions' => [
'style'=>'width: 10%',
],
'editableOptions' => [
'header'=>'State',
'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
'data'=>Orders::getOrdersStati(),
'options' => ['class'=>'form-control', 'prompt'=>'Статус...'],
],
],
public function actionIndex()
{
$searchModel = new Orders();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if (isset($_POST['hasEditable']))
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$model = new Orders();
$stateId = YII::$app->request->post('editableKey');
$model = Orders::findOne($stateId);
$post = [];
$posted = current($_POST['Orders']);
$post['Orders'] = $posted;
if ($model->load($post))
{
if($model->save())
{
if (isset($posted['State']))
{
$output = $model -> State;
}
$out = Json::encode(['output'=>$output, 'message'=>'']);
}
}
echo $out;
die;
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
Answer the question
In order to leave comments, you need to log in
How to display a modal window on a condition?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question