Hi, I have this code
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'attribute' => 'jefe_directo',
'model' => $model,
'source'=>$this->createUrl('/usuario/getJefe'),
'options'=>array(
'minLength'=>'1',
),
'htmlOptions'=>array(
'style'=>'width: 100%;',
'placeholder' => 'Input',
),
));
And the controller
public function actionGetJefe()
{
$res =array();
if (isset($_GET['term'])) {
$sentencia = "SELECT DISTINCT CONCAT ( dni, ' - ', nombre, ' ', apellidos ) FROM usuario WHERE dni LIKE :qterm OR nombre LIKE :qterm OR apellidos LIKE :qterm ORDER BY dni, nombre ASC";
$command =Yii::app()->db->createCommand($sentencia);
$command->bindValue(":qterm", '%'.$_GET['term'].'%', PDO::PARAM_STR);
$res =$command->queryColumn();
}
echo CJSON::encode($res);
Yii::app()->end();
}
The autocomplete itself is working. I can input one of the three fields (dni, nombre, apellidos) and it does the search.
Now one I send it to the server I want the value to be the row id (because it’s a foreign key).
¿How can I do this?