Yiibooster TBSelect2 not displayed

674 Views Asked by At

In my view I have this code:

echo $form->select2Row($model, 'Zustelladresse', array(
            'asDropDownList' => false,
            'options' => array(
                'placeholder' => "Zustelladresse",
                'width' => '100%',
                'closeOnSelect' => true,
                'minimumInputLength'=>1,
                'initSelection' => "js:function (element, callback) {
                            var selected_data = new Object;
                            selected_data.id = '123';
                            selected_data.text = 'Test';
                            callback(selected_data);
                        }",
                'ajax' => array(
                    'url' => Yii::app()->createUrl('address/zustelladresse'),
                    'dataType' => 'json',
                    'data' => 'js:function(term,page) { if(term && term.length){ return { zustelladresse: term };} }',
                    'results' => 'js:function(data,page) { return {results: data}; }',
                ),
            )));

Created html: Output Html

Why is created only label and hidden input?

1

There are 1 best solutions below

0
On

YiiBooster widgets are quite tricky to debug, if anything is wrong they just don't show. If you still need the answer, I successfully displayed a select2 widget with this code:

$form->select2Row($model, 'attribute_name', array(
   'data' => array('1'=>'value1,'2'=>'value2'),
   'htmlOptions'=>array(
     'style' => 'width:600px',
     'multiple' => true,
   ),
   'options'=>array('placeholder'=>'Please make a selection'),
));

I'd suggest you to start from this code and add up your options one by one, and see if anything breaks.