私は YII を初めて使用し、質問があります...次のようなモデルがあります
Person {
$id ;
$name ;
$address ;
}
Car{
$id ;
$carLicenseNumber ;
$person_id ; // BELONGS TO PERSON
}
私はCJuiAutoCompleteを持っていますが、更新したいときにフィールドに人の名前を表示する方法がわかりません
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model'=>$model,
'id'=>'person',
'name'=>'person',
'attribute'=> 'person->name', // I WANT THIS but no idea how to do this ...
'source'=>$this->createUrl('person/suggestPerson'),
'options'=>array(
'delay'=>150,
'minLength'=>2,
'showAnim'=>'fold',
'select'=>"js:function(event, ui) {
$('#label').val(ui.item.label);
$('#temp_person_id').val(ui.item.id);
}"
),
'htmlOptions'=>array(
'size'=>'40'
),
));
属性に person->name を表示するには?
注: $model は Car インスタンスです
のような一時変数を使用しようとしました
$temp = $model->person->名前; 次に、$temp を 'attribute'=>$temp に割り当てます。これはうまく機能します ...
テキストフィールドまたはオートコンプリートフィールドに関連フィールドを割り当てる適切な方法を知りたいだけです。