hi yii people. i’m fairly new to yii and i’m having this problem.
Table aliados has columns ‘id’, ‘name’ and a bunch of other stuff.
Table centro_medico has columns ‘id’ and ‘name’.
Table aliados_centro_medico has columns aliados_id and centro_medico_id.
In a different view (solicitudes/_form) i have an autocomplete for ‘aliados.name’, when you choose the right one, it has to take the ‘id’ that ‘aliados’, check table ‘aliados_centro_medico’ with that ‘aliados_id’, to see which 'centro_medico_id’s are related to it… then, with the 'centro_medico_id’s that i got from that search, i have to search table ‘centro_medico’ for the names of those ‘centro_medico’, and put all those names in a DropDownList.
I can do the search, although i’m not sure it’s right… however i don’t know how to put the results in a DropDownList, or get it from the function into the view.
Some guidance would be appreciated.
This is my search, and it’s in CentroMedico model
public function getCentroAliado(){
if(Yii::app()->user->getState('perfil')==4){
$aliados_id=Yii::app()->user->getState('aliados_id');
}
else
{
$aliados_id=$_POST['Solicitudes']['aliados_id'];
}
$criteria = new CDbCriteria;
$criteria->select='nombre';
$criteria->alias='cm';
$criteria->join="INNER JOIN aliados_centro_medico acm on (cm.id=acm.centro_medico_id) and acm.aliados_id=:aliados_id";
$criteria->params=array(':aliados_id'=>$aliados_id);
$result=CentroMedico::model()->findAll($criteria);
}