【发布时间】:2014-04-27 15:37:28
【问题描述】:
我想在文本框中使用名称自动完成。但是,名称分为列,first_name,last_name。我有以下代码。
查看
$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
'attribute'=>'CONSULTANT',
'model'=>$invoices,
'sourceUrl'=>array('SugarContacts/InvoicesNameList'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'2',
'select'=>"js:function(event, ui) { $('#Invoices_CONSULTANT').val(ui.item.id); getAddress(ui.item.id,'billing');} "
),
'htmlOptions'=>array(
'style'=>'height:20px;',
'id'=>"Invoices_CONSULTANT_search",
"size"=>"50",
'name'=>"Invoices[CONSULTANT]",
),
));
ccontroller
公共函数操作() { 返回数组(
'ProjectsNameList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'Projects', //My model's class name
'attribute'=>'PROJECT', //The attribute of the model i will search
),
'ProjectsAreaList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'Projects', //My model's class name
'attribute'=>'AREA', //The attribute of the model i will search
),
'BidsContactList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'SugarContacts', //My model's class name
'attribute'=>'first_name', //The attribute of the model i will search
),
'BidNoList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'Bids', //My model's class name
'attribute'=>'BIDNO', //The attribute of the model i will search
),
'BidsClientRefList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'Bids', //My model's class name
'attribute'=>'CLIENTREF', //The attribute of the model i will search
),
'BidsAreaList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'Bids', //My model's class name
'attribute'=>'AREA', //The attribute of the model i will search
),
'OrdersconsultantsNameList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'SugarContacts', //My model's class name
'attribute'=>'first_name', //The attribute of the model i will search
),
'InvoicesNameList'=>array(
'class'=>'application.extensions.EAutoCompleteAction',
'model'=>'SugarContacts', //My model's class name
'attribute'=>'name', //The attribute of the model i will search
),
);
}
型号
public function getName(){
return $this->first_name . " " . $this->last_name;
}
【问题讨论】:
标签: php yii autocomplete