1
<?php echo CHtml::dropDownList('Category', $model -> cate_id, CHtml::listData(Category::model() -> findAll(), 'id', 'name'), array('empty' => 'Select Category','submit'=>array('advert/loadAdvert','id'=>'5'))); ?>

i need to get selected dropdown list value and instead of hard coding id, i have to place that value for id.

public function actionloadAdvert($id) {
    $issueDataProvider = new CActiveDataProvider('Advert', array('criteria' => array('condition' => 'cate_id=:cate_id', 'params' => array(':cate_id' => $id), ), 'pagination' => array('pageSize' => 1, ), ));
    $this -> render('advertisement', array('model' => Advert::model(), 'issueDataProvider' => $issueDataProvider, ));
}

also what is the best book or resources for learning yii.

j0k
  • 22,600
  • 28
  • 79
  • 90
Viswa
  • 3,211
  • 5
  • 34
  • 65
  • Your question is really unclear. You've got code for outputting a dropdown list, and then a function that renders the advertisement view. You then ask about getting a selected dropdown list value - are you trying to pass the value from the dropdown to your function? If so, what's your specific issue? Submitting the form? Reading the form data? Trying to do it with ajax? Getting the value from the form? We probably need to see your submit code, as well as the controller method to handle the submit. – ernie Dec 05 '12 at 17:20

1 Answers1

1
<?php
echo CHtml::dropDownList(
    'Category',
    $model->cate_id,
    CHtml::listData(Category::model()->findAll(), 'id', 'name'),
    array(
        'empty'    => 'Select Category',
        'onchange' => 'document.location.href = "/advert/loadAdvert/id/" + this.value',
    )
);
?>
JonathanStevens
  • 472
  • 3
  • 9