Problem with updating dependent DropDownList

Hi All

I have created a dependent DropDownList using http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown/. Now the problem I am facing is When I have to update the form then I have to select the values of all drop down list again. Since there are around 5-6 dependent drop down list so it is a little problematic. Is there any way with which i don’t have to select it again and again while updating a form.

Thanks.

Hi All

Its been a while and still no reply.

Is there anyone who can help me out with this problem???

Please.

Thanks.

Only an idea, I didn’t test it.

Did you try jquery-cascade?

Hi,

Where are the key, values are from?

If they are coded at Model, you may follow this:

Model


class Member extends CActiveRecord

{

    const GENDER_MALE=1;

    const GENDER_FEMALE=2;


    public function getGenderOptions()

    {

        return array(

                self::GENDER_MALE=>'남자',

                self::GENDER_FEMALE=>'여자',

                );

    }


    public function getGenderText()

    {

        $genderOptions=$this->genderOptions;

        return isset($genderOptions[$this->gender]) ? $genderOptions[$this->gender] : "unknown ({$this->gender})";

    }

}



_form.php




        <div class="row">

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

                <?php echo $form->dropDownList($model,'gender',$model->getGenderOptions()); ?>  

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

        </div>



view.php




                array(

                    'name'=>'gender',

                    'value'=>CHtml::encode($model->getGenderText()),

                ),  



_view.php




        <b><?php echo CHtml::encode($data->getAttributeLabel('gender')); ?>:</b>

        <?php echo CHtml::encode($data->getGenderText()); ?>

        <br />



If you need the key/value from another table, refer the book Agile Web Application Development with Yii 1.1 and PHP5. It helped me.