Drop Down
selection of sub_section based on section :
Section :
<?php echo $form->dropDownList($model,'sec_code',CHtml::listData(Sections::model()->findAll(),'sec_code','sec_name'),
array(
'prompt'=>'Select Section',
'ajax'=> array(
'type' => 'POST',
'url'=>CController::createUrl('Inward/Sec'),
'update'=>'#'.CHtml::activeId($model,'sub_scode'),
)
)
);
?>
Sub_section :
<?php echo $form->error($model,'Name of the Section Asst.'); ?>
<?php echo $form->labelEx($model,'sub_scode'); ?>
<?php echo $form->DropDownList($model,'sub_scode',CHtml::listData(SubSections::model()->findAllByAttributes(array('sec_code'=>$model->sec_code)),'sub_scode','sub_section'),array('prompt'=>'Select Sub Section')); ?>
<?php echo $form->error($model,'sub_scode'); ?>
selection of sub_section based on section :
In Views
Section :
<?php echo $form->dropDownList($model,'
array(
)
)
);
?>
Sub_section :
<?php echo $form->error($model,'Name of the Section Asst.'); ?>
<?php echo $form->labelEx($model,'sub_
<?php echo $form->DropDownList($model,'
<?php echo $form->error($model,'sub_
Defining action sec(Inward/Sec) in Inward controller
public function actionSec()
{
$data = SubSections::model()->findAll('sec_code=:sec_code',
array(':sec_code'=>(int) $_POST['Inward']['sec_code']));
$data = CHtml::listData($data,'sub_scode','sub_section');
foreach($data as $id => $value)
{
echo CHtml::tag('option',array('value' => $id),CHtml::encode($value),true);
}
}
{
$data = SubSections::model()->findAll(
array(':sec_code'=>(int) $_POST['Inward']['sec_code']))
$data = CHtml::listData($data,'sub_
foreach($data as $id => $value)
{
echo CHtml::tag('option',array('
}
}
No comments:
Post a Comment