Yii-Booster Select2 On Change

Hi fellows, I’m trying to simply retrieve the text content on the change event of the select2 widget in yii-booster.

I get the val property value but not the text one. Do you have any idea ?


                $this->widget('bootstrap.widgets.TbSelect2', array(

                'asDropDownList' => true,

                'name' => 'num_month',

                'data' => array(1=>'1 month',2=>'2 months'),

                'options' => array(

                    'width' => '45%',

                    'tokenSeparators' => array(',', ' '),


                'events' =>array('change'=>'js:function(e) 


                        $("#amountm").text((e.val*9+9)+" € (" + e.text + ")");




I’ve tried with choice, added and name. Nothing got me the text content of the selection.

Did anyone solve this? I have the same symptoms. The Yii Booster page does not have examples on how to correctly preload data and I suspect that the extension is unable to correctly retrieve the ‘text’ field just by looking at how the actual Select2 plugin works (http://ivaynberg.github.io/select2/). It seems an associative array is passed in as the data parameter.

Additionally, the placeholder does not get populated correctly and just says, "undefined" in the dropbox.

I have some code similar to yours, did a console.log() on your ‘e’ variable under events->change, and I was able to see the selected text. Here’s my change function:

'change'=>'js: function(e) {




In order to get the placeholder to work, I had to add a blank item at the beginning of my data array. Hope this example helps:


	$this->widget('bootstrap.widgets.TbSelect2', array(




			'1'=>'Item 1',

			'2'=>'Item 2',



			'placeholder'=>'Select an item',