It seems to me what you need to do is look at the $ _POST variables to see which dependent drop-down list was selected, and pre-visualize it when form validation fails, so the default Yii validation errors work. Using this link as an example:
First, reorganize part of the method actionDynamiccities()into a separate public (invalid) method in your controller:
public function getCitiesList($country_id) {
$data=Location::model()->findAll('parent_id=:parent_id',
array(':parent_id'=>(int) $country_id));
return CHtml::listData($data,'id','name');
}
Then consolidate your reorganized AJAX action as follows:
public function actionDynamiccities()
{
$data = $this->getCitiesList($_POST['country_id']);
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
_form.php div #city_id, AJAXed , PHP-, :
<div id="city_id">
<?php if(isset($_POST['city_id'])): ?>
<?php foreach($this->getCitiesList($_POST['country_id']) as $value=>$name): ?>
<?php echo CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true); ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
, $_POST ['country_id'], , .
, .
, . !