Web Development

Controller Method

In the method you need to use, send the records from the model to the view.

class DealsController extends Controller
{
    public function actionCreate()
    {
        $model=new Deal;
        $this->render('create', array(
            'model'=>$model,
            'categories' => Category::model()->findAll()
        ));
    }
}

View

We will be using CHtml::listData for formatting data to be usable for the dropDownList method:

<div class="form-group">
    <?php echo $form->labelEx($model,'category_id'); ?>
    <?php echo $form->dropDownList($model,'category_id', CHtml::listData($categories, 'id', 'name'), array('class' => 'form-control')); ?>
    <?php echo $form->error($model,'category_id'); ?>
</div>