Questions About Typeahead

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:


$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





        'name' => 'demo-typeahead',

        'options' => array(

            'source' => $comunas,

            'items' => 4,

            'matcher' => <<<ENDL

    js:function(item) {

    return ~item.toUpperCase().indexOf(this.query.toUpperCase());







Best regards

Haven’t used booster, but seems like it has some useful options like valueAttribute and displayAttribute:

Check the docs.

Orey, thank you very much. The extension you recommended, works perfect. Even YiiBooster brings built :S

Best regards!