<?php echo $form->labelEx($model, 'CategoriaId', array('class' => 'control-label')); ?> <?php echo $form->dropDownList($model, 'CategoriaId', CHtml::listData(Categoria::model()->findAll("CategoriaSta='ALTA'"), 'CategoriaId', 'CategoriaNom'), array('empty' => 'Sin categoria', 'class' => 'span3 chosen', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('evento/cargarSubcategorias'), 'update' => '#Evento_CategoriaSubId', 'success' => 'function(data){$("#Evento_CategoriaSubId").html(data);updateChosen(".chosen");}'))); ?> <?php echo $form->error($model, 'CategoriaId'); ?> </div> <div class='control-group'> <?php echo $form->labelEx($model, 'CategoriaSubId', array('class' => 'control-label')); ?> <?php echo $form->dropDownList($model, 'CategoriaSubId', CHtml::listData(Categorialevel1::model()->findAllByAttributes(array('CategoriaId' => $model->CategoriaId)), 'CategoriaSubId', 'CategoriaSubNom'), array('empty' => 'Sin subcategoria', 'class' => 'span3 chosen')); ?> <?php echo $form->error($model, 'CategoriaSubId'); ?> </div> <div class='control-group'> <?php echo $form->labelEx($model, 'ForoId', array('class' => 'control-label')); ?> <?php echo $form->dropDownList($model, 'ForoId', CHtml::listData(Foro::model()->findAll(), 'ForoId', 'ForoNom'), array('empty' => 'Sin foro', 'class' => 'span3 chosen')); ?> <?php echo $form->error($model, 'ForoId');
public function actionCargarSubcategorias() { $this->perfil(); $data = Categorialevel1::model()->findAll('CategoriaId=:id', array(':id' => (int) $_POST['Evento']['CategoriaId'])); echo CHtml::tag('option', array('value' => '0'), 'Sin Subcategoria', true); foreach ($data as $id => $value) { echo CHtml::tag('option', array('value' => $value->CategoriaSubId), CHtml::encode($value->CategoriaSubNom), true); } }