Friday, February 21, 2014

Yii Dropdown creation in form

                $products = Products::model()->findAll();
		
		$prodlist = CHtml::listData($products,'id', 'name');
		
		
			 
    $form->dropDownList($model, 'product_id',$prodlist, array('prompt'=>'Select Product'));
* from above lines,
* $products is the object that holds all data from Products model;

* $prodlist lists the data "id" is the value and "name" is the text for dropdown

No comments:

Post a Comment