Update A Checkboxlistinlinerow

hi there,

in my view, i have:


echo $form->dropDownListRow($model, 'department_id', $departments, array(

    'prompt' => '> Select Department',

    'ajax' => array(

        'type' => 'GET',

        'url' => CController::createUrl('departmentajax'),

        'update' => '#workflows',

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

        )));

echo $form->checkBoxListInlineRow(

            $model, 'workflows', CHtml::listData(Workflow::model()->findAll(), 'id', 'name')

    );

The idea is every department in the dropdown list, has some workflows related.

how i can show checkboxes depends to the dropdownlist selection.

in my controller:


$sql = 'SELECT workflow.id, workflow.name FROM workflow INNER JOIN department_workflow

                    ON workflow.id=department_workflow.workflow_id

                    WHERE department_workflow.department_id='.$department_id;

            $result = Yii::app()->db->createCommand($sql)->queryAll();

          

            $listdata = CHtml::listData($result, 'id', 'name');

$listdata, should be the checkboxes that i need to show.

Thank you!

please see link for conditional dropdown list.

Thank you for your answer skworden, but this would work for 2 dropdown lists,

I need a dropdown list and a checkbox…

this loop :


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

    {

        echo CHtml::tag('option',

                   array('value'=>$value),CHtml::encode($name),true);

    }

works only with dropdown list!

No one :mellow:

switch the second to show a checkbox list instead of a dropdown list. it’s the same concept