dear community,
I’m starting to work with yiibooster. I wanted to use type-a-head and is running me perfect, but I have a problem. I want to show the name, but save the ID, how can I do this?
What I have is this:
Controller
$sqlcomunas = Yii::app()->db->createCommand('select COMUNA_NOMBRE from comuna')->queryAll();
$comunas = array();
for($i = 0; $i < sizeof($sqlcomunas); $i++){
$comunas[] = $sqlcomunas[$i]["COMUNA_NOMBRE"];
}
view create
<?php $comunas; ?>
<?php echo $this->renderPartial('_form', array('model'=>$model, 'comunas'=>$comunas)); ?>
view _form
<?php
$this->widget(
'bootstrap.widgets.TbTypeahead',
array(
'name' => 'demo-typeahead',
'options' => array(
'source' => $comunas,
'items' => 4,
'matcher' => <<<ENDL
js:function(item) {
return ~item.toUpperCase().indexOf(this.query.toUpperCase());
}
ENDL
),
)
);
?>
Best regards