ajax dropdown problem With Extension Echosen

(Rafael Rosales) #1

This great extension. i have a little problem, i cannot make it work for dynamic dropdownlist. As I can solve this problems?

[size="2"]I have in my BD a[/size] tabla [size="2"]Clientes and one I join related signatories to many for CodCliente, that the primary key in the [/size][size="2"]tabla is Clientes and in the [/size]tabla firmantes [size="2"]I have the field IdCliente for the relation.[/size]

[size="2"]I have the [/size]controller function:

public function actionActualizarFirmantes() {

        $model = Clientes::model()->findByPk($_POST['idCodigo']);

        //To fill firmantes

        $data = CHtml::listData($model->firmantes, 'CI', 'Nombre');//I look for firmantes in the tabla here the CI and the names of the cliente selected in the tabla clientes

        $firmantes = "";

        foreach ($data as $value => $name)

                $firmantes .= CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);

        // return data (JSON formatted)

        echo CJSON::encode(array(

                'firmantes' => $firmantes



In the form the extension EChosen I put her in this way:


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

                                'target' => 'select',

                                'useJQuery' => true,

                                'debug' => false,



In the form: I have two dropDownList:

First dropDownList:

<td colspan="3" title="Select the cliente">

                        <?php echo $form->labelEx($model, 'Cliente'); ?>


                        echo $form->dropDownList($model, 'CodCliente', CHtml::listData(Clientes::model()->findAll(array('order' => 'Descripcion')), 'CodCliente', 'Descripcion'), array(

                                'ajax' => array(

                                'type' => 'POST',

                                'url' => CController::createUrl('datossal/actualizarFirmantes'),

                                'dataType' => 'json',

                                'data' => array('idCodigo' => 'js:this.value'),

                                'success' => 'function(data) {






<?php echo $form->error($model, 'CodCliente'); ?>


Second dropDownList, where the names of the people related with that selected cliente must be shown:

<td title="The authorized are  shown to sign invoices when selecting the customer">

   <?php echo $form->labelEx($model, 'CI'); ?> <?php echo $form->dropDownList($model, 'CI', array()); ?>

   <?php echo $form->error($model, 'CI'); ?>  


I know that there must be options with the extension but I do not know them, I wait if somebody is experienced with this, I need to make the filter for the better the quest, I clarify with this.

I put some Imagery to show better here:

My first dropDownList with the filter made by the extension:

The image without updating second dropDownList ( Authorized Person ):

This third image is like appear the two dropDownList without the extension Echosen, but they are many clientes , which is why I make the filter:

(Rafael Rosales) #2

Already this resolved into other after in the forum in Spanish