Chtml Activeid And Autcomplete

Hi all!

Sorry for my bad english…

I’m using this method to make an autocomplete field http://www.yiiframework.com/wiki/217/custom-autocomplete-display-and-value-submission/ but I want to extended for 3 fields, but when I put two Chtml::activeId it only works the last one!




<?php

// ext is a shortcut for application.extensions

Yii::import('zii.widgets.jui.CJuiAutoComplete');

$this->widget('ext.myAutoCompleteExtended', array(

	    'name' => 'producto_autocomplete',

	    'sourceUrl' => $this->createUrl('facturacion/autocompleteProducto'),

	// attribute_value is a custom property that returns the 

	// name of our related object -ie return $model->related_model->name

	    'value' => $detalleFactura->isNewRecord ? '': $detalleFactura->producto->Producto,

	    'options' => array(

		        'minLength'=>2,

		        'autoFill'=>false,

		        'focus'=> 'js:function( event, ui ) {

		            $( "#producto_autocomplete" ).val( ui.item.name );

		            return false;

		        }',

		        'select'=>'js:function( event, ui ) {

		            $("#'.CHtml::activeId($detalleFactura,'Producto_id').'")

		            .val(ui.item.id);

		            return false;

		        }',

		        'select'=>'js:function(event, ui) {

			  $("#'.CHtml::activeId($detalleFactura,'Precio').'")

			     .val( ui.item.price );

			     return false;

			}',

			),

		    'htmlOptions'=>array('class'=>'input-1', 'autocomplete'=>'off'),

		    'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {

		        return $( "<li></li>" )

		        .data( "item.autocomplete", item )

		        .append( "<a>" + item.name +  "</a>" )

		        .appendTo( ul );

		    };'

		));

		?>



Got solved!

I have two select statement in the js function, all I do is to move the two CHtml::activeId to only one select




'select'=>'js:function( event, ui ) {

      $("#'.CHtml::activeId($detalleFactura,'Producto_id').'")

      .val(ui.item.id);

      $("#'.CHtml::activeId($detalleFactura,'Precio').'")

      .val( ui.item.price );

      return false;

}',