?> <?php echo $form->dropDownList($model, 'location_id', $locations, array('id' => 'ap_location', 'ajax' => array('type' => 'GET', 'url' => $this->createUrl('/apartments/main/getSublocations'), 'data' => 'js:"ap_location="+$("#ap_location").val()', 'success' => 'function(result){ $("#ap_sublocation").html(result); $("#ap_sublocation").change(); }'))); ?> <?php echo $form->error($model, 'location_id'); ?> </div> <div class="rowold" id="sublocation_row" <?php $valueSubLocation = Apartment::getSublocationsOfLocation($model->location_id); if ($model->sublocation_id != 0) { Yii::app()->clientScript->registerScript('selectSublocation', "\n \$('select[name=\\'options\\']').find('option[value=\\'" . $model->sublocation_id . "\\']').attr('selected',true);\n "); } ?> > <?php echo $form->labelEx($model, 'sublocation_id'); ?> <?php echo $form->dropDownList($model, 'sublocation_id', $valueSubLocation, array('id' => 'ap_sublocation', 'class' => 'width240', 'ajax' => array('type' => 'GET', 'url' => $this->createUrl('/apartments/main/getRegions'), 'data' => 'js:"sublocationID="+$("#ap_sublocation").val()', 'success' => "function(result) {\n if (result!='<option value=\"0\">Выберите регион</option>')\n {\n \$('#ap_region').parent().css('display', 'block');\n \$('#ap_region').html(result);\n \$('#ap_region').change();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t else\n\t\t\t\t\t\t {\n\t\t\t\t\t\t \$('#ap_region').parent().css('display', 'none');\n\t\t\t\t\t\t }\n\n\t\t\t\t\t\t}"))); ?> <?php echo $form->error($model, 'sublocation_id'); ?>