/** * Delete multiple existing State model. * For ajax request will return json object * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionBulkDelete() { $request = Yii::$app->request; $pks = $request->post('pks'); // Array or selected records primary keys foreach (State::findAll(json_decode($pks)) as $model) { $model->delete(); } if ($request->isAjax) { /* * Process for ajax request */ Yii::$app->response->format = Response::FORMAT_JSON; return ['forceClose' => true, 'forceReload' => true]; } else { /* * Process for non-ajax request */ return $this->redirect(['index']); } }
<?php echo $form->field($model, 'stu_padd')->textArea(['maxlength' => 255]); ?> <?php echo $form->field($model, 'stu_padd_country')->dropDownList(ArrayHelper::map(\app\models\Country::find()->all(), 'country_id', 'country_name'), ['prompt' => '---Select Country---', 'onchange' => ' $.get( "' . Url::toRoute('dependent/ustud_p_state') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($model, 'stu_padd_state') . '" ).html( data ); } );']); ?> <?php echo $form->field($model, 'stu_padd_state')->dropDownList(ArrayHelper::map(\app\models\State::findAll(['state_country_id' => $model->stu_padd_country]), 'state_id', 'state_name'), ['prompt' => '---Select State---', 'onchange' => ' $.get( "' . Url::toRoute('dependent/ustud_p_city') . '", { id: $(this).val() } ) .done(function( data ) { $( "#' . Html::getInputId($model, 'stu_padd_city') . '" ).html( data ); } );']); ?> <?php echo $form->field($model, 'stu_padd_city')->dropDownList(ArrayHelper::map(\app\models\City::findAll(['city_state_id' => $model->stu_padd_state]), 'city_id', 'city_name'), ['prompt' => '---Select City---']); ?> <?php echo $form->field($model, 'stu_padd_pincode')->textInput(['maxlength' => 6]); ?>