Hello out there,
I am on my first steps with YiiBoilerplate and this is just sooo amazing.
The YiiBooster gives so many quick wins, fantastic.
I am right now trying to have a TbSelect2 inside a TbActiveForm.
The TbSelect2 fetches data via a AJAX/JSON from the controller.
That works fine.
I can also selct something, but how can I put the selcted ID (not the text of course) into the appropiate form field?
Any ideas?
This is my code so far:
(the out-commented echo is the default CRUD created form field for this controller. So I want to use the selected ID from the TBSelect2 as the "genus_id" of the model.)
//echo $form->textFieldRow($model,'genus_id',array('class'=>'span5'));
$this->widget('bootstrap.widgets.TbSelect2', array(
'asDropDownList' => false,
'name' => 'genus_id',
'model'=>$model,
'options'=>array(
'width' => '40%',
'minimumInputLength' => 2,
'placeholder'=>'Choose Genus',
'allowClear'=>true,
'ajax'=>array(
'url'=>Yii::app()->createUrl('CfNames/list'),
'dataType'=>'jsonp',
'data' => 'js: function(term,page) {
return {
q: term,
};
}',
'results' => 'js:
function(data,page){
return {results: data.list
};
}',
),
),
));
Thanks for any hints to put me into the right direction…
gb