"Do you know How to display the data in drop down list?" This tutorial will help you to display the array data or model data in drop down list in different way.... Read More »
"Do you know How to display the data in drop down list?" This tutorial will help you to display the array data or model data in drop down list in different way.... Read More »
This turorial have the details of dynamic data insertion to dropdownlist using ajax. I added the source code below for this concept. We have two dropdownlist in form “usercategory”,”usertype”. When we change the usercategory, usercategory related usertype will show in “usertype” dropdownlist.In view.php <div class="row"> <?php echo $form->labelEx($model,'usercategory'); ?> <?php $categories=Yii::app()->Datacomponent->usercategory(); echo $form->dropdownlist($model, 'usercategory', $categories, array( 'empty'=>'Select Category ', 'ajax'=>array( 'type'=>'POST', 'url'=>CController::createUrl('default/usertype'), 'update'=>'#User_usertype', 'data'=>array('categoryid'=>'js:this.value'), ), ) ); ?> <?php echo […]... Read More »
I added the code to submit the yii form When we select the value from Chtml dropdownlist box. <div class="search-form" style="display:block"> <div class="wide form"> <?php $form=$this->beginWidget('CActiveForm', array( 'action'=>Yii::app()->createUrl($this->route), 'method'=>'get', )); ?> <div class="row"> <?php echo $form->labelEx($model,'type'); ?> <?php $types=array("1"=>"Type1","2"=>"Type2"); echo $form->dropDownList($model,'type',$types, array( 'onchange'=>CHtml::ajax(array( 'success'=>"$('.search-form form').submit()", )), ) ); ?> </div> </div> </div>... Read More »
I added the code for yii dropdownlist to the following actions like Dropdownlist ajax, Ajax response etcCHtml dropDownList: AjaxCHtml dropDownList: Ajax Response(Ex1)CHtml dropDownList: Ajax Response(Ex2)CHtml dropDownList: Ajax Response(Ex3)CHtml dropDownList: Ajax <?php /** CHtml dropDownList Ajax**/ $type=array("1"=>"Type 1","2"=>"Type 2"); echo $form->dropdownlist( $model, 'type', $type, array( 'empty'=>'Select Type', 'ajax'=>array( 'type'=>'POST', 'url'=>CController::createUrl('user/type'), 'data'=>array('typeid'=>'js:this.value'), ), ) ); ?> CHtml dropDownList: Ajax Response(Ex1) <?php /** Update After Get Response **/ $type=array("1"=>"Type 1","2"=>"Type 2"); echo $form->dropdownlist( […]... Read More »
Using CHtml class we are creating dropDownList in yii framework. This post will help you to understand about how to create dropDownList in different method, How to assign value, how to get dropDownList value in controller, dropDownList value from database, dropDownList validation in model yii framework.Default EmptyDropDownListDropDownList Value In ControllerDropDownList EventDefault EmptyEmpty string, specifies the text corresponding to empty selection. Its value is empty. The ’empty’ option can also be […]... Read More »