CJuiAutoComplete for create- and update-view

Hi all,

I am trying to use the CJuiAutoComplete for both views create and update.

I wan’t to show the recommendator’s name and submit his id on create.

On update I’d like to show the recommendator’s name again by given id, but with the possibility to change the recommendator.

My code is the following:


                    echo $form->labelEx    ($model,'recommendator_id');

                    echo $form->error      ($model,'recommendator_id');

                    echo $form->hiddenField($model,'recommendator_id',array());


                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(

                        'model'     => $model,

                        'attribute' => 'recommendator',

                        'sourceUrl' => $this->createUrl('customer/getAutocompleteList'),

                        // additional javascript options for the autocomplete plugin

                        'options'   => array(

                            'showAnim' => 'fold',

                            'select'   => "js:function(event, ui) {

                                              $('#Customer_recommendator_id').val(ui.item.id);

                                          }"

                        ),

                        'htmlOptions' => array(

                            'class'  => 'autocompleteCustomer',

                        )

                    ));



This works well for create but on update I get the following error message:

What is it I am doing wrong? Can someone help me please?

Thx

What is the attribute ‘recommendator’? Is it an object perhaps?

Greg

thx,

you are right. ‘recommendator’ was a parent-child-relation to same model.

my solution was to add an fake-attribute to the model and change line


'attribute' => 'recommendator', 

to


'attribute' => 'fakeRecommendator', 

and it works fine.

Excuse me, can I see the source code for the model, controller, and the form? I still have a problem with update , too. The name in the textfield that we give autocomplete didn’t show up. Thank you. :)