After some search I found out that ajax was the better solution.
I wanted to share what I did to help out someone
This is my _form
<div class="row">
<?php echo $form->labelEx($model,'placa'); ?>
<?php
$ajaxConservacao = CHtml::ajax(array(
'type' => 'GET',
'url' => array('/movimentacao/conservacaoPatrimonio'),
'data' => array (
'patrimonio' => 'js:$(this).val()',
),
'update' => '#' . CHtml::activeId($model, 'cod_conservacao_ant'),
));
$ajaxSala = CHtml::ajax(array(
'type' => 'GET',
'url' => array('/movimentacao/salaPatrimonio'),
'data' => array (
'patrimonio' => 'js:$(this).val()',
),
'update' => '#' . CHtml::activeId($model, 'cod_sala_ant'),
));
echo $form->textField($model,'placa',array('disabled'=>$options, 'size'=>6,'maxlength'=>6, 'onchange' => $ajaxConservacao . $ajaxSala));
?>
<?php echo $form->error($model,'placa'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cod_conservacao_ant'); ?>
<?php
echo $form->dropDownList($model, 'cod_conservacao_ant',
$this->getConservacaoPatrimonio($model->placa),
array('disabled'=>$options)
);
?>
<?php echo $form->error($model,'cod_conservacao_ant'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'cod_sala_ant'); ?>
<?php //echo $form->textField($model,'cod_sala_ant', array('disabled'=>true)); ?>
<?php
echo $form->dropDownList($model, 'cod_sala_ant',
$this->getSalaPatrimonio($model->placa),
array('disabled'=>$options)
);
?>
<?php echo $form->error($model,'cod_sala_ant'); ?>
</div>
this is my controller
public function actionConservacaoPatrimonio($patrimonio){
$options = array('disabled'=>true);
echo CHtml::listOptions('', $this->getConservacaoPatrimonio($patrimonio), $options);
}
public function getConservacaoPatrimonio($patrimonio){
$result = array();
if($placas = Patrimonio::model()->findAllByAttributes(array('placa'=>$patrimonio)))
foreach($placas as $placa) {
$reg = array();
$reg['cod_conservacao'] = $placa->cod_conservacao;
$reg['descr_conservacao'] = $placa->codConservacao->descr_conservacao;
$result[] = $reg;
}
return CHtml::listData($result, 'cod_conservacao', 'descr_conservacao');
}
public function actionSalaPatrimonio($patrimonio){
$options = array('disabled'=>true);
echo CHtml::listOptions('', $this->getSalaPatrimonio($patrimonio), $options);
}
public function getSalaPatrimonio($patrimonio){
$result = array();
if($placas = Patrimonio::model()->findAllByAttributes(array('placa'=>$patrimonio)))
foreach($placas as $placa) {
$reg = array();
$reg['cod_sala'] = $placa->cod_sala;
$reg['descr_sala'] = $placa->codSala->descr_sala;
$result[] = $reg;
}
return CHtml::listData($result, 'cod_sala', 'descr_sala');
}
So with this I don’t need any rule on the model and it works just the way I needed.