public function actionSubcat() { $out = []; $isEmpty = true; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $cat_id = $parents[0]; $out = Group::getDropDownList($cat_id); //$out = [['id'=>'1', 'name'=>$cat_id],['id'=>'2', 'name'=>json_encode(Group::getDropDownList($cat_id))]]; $isEmpty = false; $selected = ''; if (!empty($_POST['depdrop_params'])) { $params = $_POST['depdrop_params']; $selected = $params[0]; // get the value of input-type-1 $param2 = $params[1]; // get the value of input-type-2 } echo Json::encode(['output' => $out, 'selected' => $selected]); } } if ($isEmpty) { echo Json::encode(['output' => [['id' => '1', 'name' => '<sub-cat-name1>'], ['id' => '2', 'name' => '<sub-cat-name2>']], 'selected' => '']); } }