I’m new to Yii framework. Now, I’m using ext.combobox.EJuiComboBox
to create a dependent dropdown.
View
</br>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'bill-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'company_id'); ?>
<?php
$this->widget('ext.combobox.EJuiComboBox', array(
'model' => $model,
'attribute' => 'company_id',
// data to populate the select. Must be an array.
//'data' => $model->getAllModels(),
'data' => CHtml::listData(Company::model()->findAll(), 'id', 'name'),
// options passed to plugin
// Options passed to the text input
'options' => array(
// JS code to execute on 'select' event, the selected item is
// available through the 'item' variable.
),
// Options passed to the text input
'htmlOptions' => array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('bill/getProjects'),
'update'=>'#'.CHtml::activeId($model,'project_id'),
'beforeSend' => 'function(){
$("#page").addClass("loading");}',
'complete' => 'function(){
$("#page").removeClass("loading");
$("#' . CHtml::activeId($model,'project_id') . '").trigger("change");
}',
))
)); ?>
<?php echo $form->error($model,'company_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'project_id'); ?>
<?php echo $form->dropDownList($model,'project_id', CHtml::listData(Project::model()->findAll('company_id= :company', array(':company'=>$model->company_id)), 'id', 'name'), array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('bill/getTasks'),
'update'=>'#'.CHtml::activeId($model,'task_id'),
'beforeSend' => 'function(){
$("#page").addClass("loading");}',
'complete' => 'function(){
$("#page").removeClass("loading");}',
)));
?>
<?php echo $form->error($model,'project_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'task_id'); ?>
<?php echo $form->dropDownList($model,'task_id', CHtml::listData(Task::model()->findAll('project_id= :project', array(':project'=>$model->project_id)), 'id', 'name')); ?>
<?php echo $form->error($model,'task_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'foo'); ?>
<?php echo $form->textField($model,'foo',array('size'=>60,'maxlength'=>64)); ?>
<?php echo $form->error($model,'foo'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
But, it isn’t working with this combobox. How can i make it work, such that when i select value from first the dependent should get automatically selected.