public function actionLocality() {
$out = [];
if (isset($_POST['depdrop_parents']))
{
$ids = $_POST['depdrop_parents'];
//print_r($ids);
$area = $ids[0];
$region = $ids[1];
$type = $ids[2];
if ($type != null) {
$list = Locality::find()->select(['id_locality','name_locality'])->where(['area' => $area,'region'=>$region,'type_locality'=>$type])->asArray()->all();
$selected = null;
if (count($list) > 0)
{
foreach ($list as $i => $locality) {
$out[] = ['id' => $locality['id_locality'], 'name' => $locality['name_locality']];
}
// Shows how you can preselect a value
echo Json::encode(['output' => $out, 'selected'=>'']);
return;
}
}
}
echo Json::encode(['output'=>'', 'selected'=>'']);
}