(Solved)Dependant Dropdownlist Help

hi guys need your help again i’m trying to make some dependant dropdownlists but the issue is that it is showing to me php 500 error and do not know why or how to solve it… any assistance will be very much aprecciated…

this is the function to look for the related value in the tables




 public function actionSelectId()

        {

           $idOperationGroup = $_POST['Name']['Id'];

           $list= Unit::model()->findAll('OperationGroupId = :idOperationGroup', array(':idOperationGroup'=>$idOperationGroup));

           $list = CHtml::listdata($list,'Id','Name');

           

            foreach($list as $valor => $Name){

                echo CHtml::tag('option',array('value'=>$valor),CHtml::encode($Name),true);

            }

        }



this code is in my view…




<div class="row">

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

                <?php echo $form->dropDownList($model,'Id',

                   CHtml::listData(OperationGroup::model()->findAll(),'Id','Name'),

                        array(

                            'ajax'=>array(

                              'type'=>'POST',

                              'url'=>CController::createUrl('Tire/SelectId'),

                              //'update'=>'#'.CHtml::activeId($model,'Unit'),                             

                            ),'prompt'=>'Seleccione'

                          )

                        ); ?>

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

	</div>



hey guys I’ve already solved the issue… let me explain to you how it works… I have 2 tables:

tbl_operation_group and tbl_unit… the units in tbl_units they belong to an operation group… tbl_opreation_group have a field wich is id… tbl_unit has a field wich is called OperationGroupId and they are related with this group… so what I was looking for was to make 2 dependant dropboxes… I mean select first the operation group and load all the units that are include in that operation group… so first I manage to create the drop boxes showing their information…




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

                <?php echo $form->dropDownList($model,'Id',

                   CHtml::listData(OperationGroup::model()->findAll(),'Id','Name'),

                        array(

                            'ajax'=>array(

                              'type'=>'POST',

                              'url'=>CController::createUrl('Tire/SelectId'),

                              'update'=>'#'.CHtml::activeId($model,'Name'),                             

                            ),'prompt'=>'Seleccione'

                          )

                        ); ?>

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



in this code I load the ID and the operation group name…also I made an ajax call type post, and I call the SelectId function wich is located in my controller and look like this…




public function actionSelectId()

        {

           

           $id = $_POST['OperationGroup']['Id'];

           $list= Unit::model()->findAll('OperationGroupId = :id', array(':id'=>$id));

           $list = CHtml::listdata($list,'Id','Name');

           

           echo CHtml::tag('option', array('value' => ''), 'Seleccione', true);

           

            foreach($list as $valor => $id){

                echo CHtml::tag('option',array('value'=>$valor),CHtml::encode($id),true);

            }

        }



in the $id i get the value of the id then in the $list i made a comparassion beetween the $id and the operationGroupId field, and finally in the list data i collect the Id and the name of the unit… so then in the foreach section i just print the results in the second dropdownlist that looks like this




<div class="row">

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

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

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

	</div>



the code works totally fine… any question please answer this thread