Well, this is all I could do, In the _form.php:
<div class="simple">
<?php echo CHtml::activeLabelEx($clientes,'idPaisCliente'); ?>
<?php echo CHtml::dropDownList('dirlab_idpais','', Paises::model()->getAllList(), array(
'prompt'=>'Seleccione...', //
'value'=>'0',
'ajax' => array(
'type'=>'POST', //request type
'url'=>'/mistery1/misteryapp/index.php?r=provincia/Dynamicprovincias', //url to call
'update'=>'#dirlab_idprovincia', //selector to update
//'data'=>'js:document.getElementById("pruebaprovincia").style.display="inline";',
//leave out the data key to pass all form values through
))); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($clientes,'idProvinciaCliente'); ?>
<?php echo CHtml::dropDownList('dirlab_idprovincia','', array(), array(
'prompt'=>'Seleccione...', //
'value'=>'0',
'ajax' => array(
'type'=>'POST', //request type
'url'=>'/mistery1/misteryapp/index.php?r=localidad/Dynamiclocalidades', //url to call
'update'=>'#dirlab_idciudad', //selector to update
//'data'=>'js:alert("prueba")',
//leave out the data key to pass all form values through
))); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($clientes,'idCiudadCliente'); ?>
<?php echo CHtml::dropDownList('dirlab_idciudad','',array(), array( 'prompt'=>'Seleccione...','value'=>'0')) ?>
</div>
in the ProvinciaController:
public function actionDynamicprovincias()
{
$data=Provincia::model()->findAll('idpais=:idpais',
array(':idpais'=>(int) $_POST['dirlab_idpais']));
$data=CHtml::listData($data,'id','descripcion');
$data[0]="Seleccione...";
ksort($data);
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
There are two lines that I add to show a "Select…" option in the drop cause it doesn't work seting it in the 'prompt'=>'Seleccione…', 'value'=>'0'.
Another thing I have to do is, in the ClientesController in the create method and in the update I had to modify this cause it doesn't save the provincia, pais, ciudad ids:
public function actionCreate()
{
$clientes=new Clientes;
if(isset($_POST['Clientes']))
{
$clientes->attributes=$_POST['Clientes'];
$clientes["dirlab_idpais"] = $_POST['dirlab_idpais'];
$clientes["dirlab_idprovincia"] = $_POST['dirlab_idprovincia'];
$clientes["dirlab_idciudad"] = $_POST['dirlab_idciudad'];
if($clientes->save())
$this->redirect(array('show','id'=>$clientes->id));
}
$this->render('create',array('clientes'=>$clientes));
}
Now it is working, saving the ids, showing the select option, but the problem is when you try to modify, how can I show this options that are saved to show it again. If this that I am doing is wrong what is the correct way. Thanks in advance.