Hi
thanks for reading this post,
I Have the Need to create a ChechBoxList starting from the selection of a list of values in the forums I found something very similar But I can not find the solution.
Link this is the solution I found but only applies to listbox. there any examples to help fill a CheckBoxList??
this is my view
<div class="row">
<?php echo $form->labelEx($model, 'Ejecutivo'); ?>
<?php
echo $form->dropDownList($model, 'id_ejecutivo', CHtml::listData(Ejecutivo::model()->findAll(), 'id_ejecutivo', 'nombre'), array(
'ajax' => array(
'type' => 'POST', //request type
'url' => CController::createUrl('usuarioejecutivodistribuidor/dynamicdistribuidor'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#'.CHtml::activeId($model,'id_distribuidor')
//'data'=>'js:javascript statement'
//leave out the data key to pass all form values through
)));
?>
<?php echo $form->error($model, 'id_ejecutivo'); ?>
</div>
</div>
<div class="row">
<?php echo $form->labelEx($model, 'id_distribuidor'); ?>
<?php echo $form->checkBoxListList($model, 'id_distribuidor', array()); ?>
<?php echo $form->error($model, 'id_distribuidor'); ?>
</div>
my controller
public function actionDynamicdistribuidor() {
//please enter current controller name because yii send multi dim array
$data = Distribuidor::model()->findAll('id_ejecutivo=:id_ejecutivo', array(':id_ejecutivo' => $_POST['UsuarioEjecutivoDistribuidor']['id_ejecutivo']));
$data = CHtml::listData($data, 'id_distribuidor', 'nombre');
foreach ($data as $value => $name) {
echo CHtml::tag('input', array('type' => 'checkbox','value' => $value,), CHtml::encode($name),true);
}
}
thanks for your help