Have A Gridview To Retrieve Selection In My View/create

Hi i’m a little new to Yii,

I have a model Client and a model Work with a Work/client_id field (FK).

I want that in Work/view/create I can click a button and search a value in Client/view/admin, retrieve the client_id and fill my Work/create/client_id…

then go on with my create form and submit my Work…

I suppose that I cannot use a dropdownlist for the many Clients in the model…

is there an easy way to do this?

I searched but I tell you that I’m a newbie, thanks

<?php echo $form->dropDownList($model,'client_id',CHtml::listData(Client::model()->findAll(),'id','name')); ?> //replace 'name' with your attribute

I guess this could much help you

if you are passing client_id to admin view then u can use like this

in the controller

$criteria=new CDbCriteria;



$model= Client::model()->findAll($criteria);

Thanks 4 the support. At the end I created an autocomplete field with the extension ejui-autocomplete-fk-field.

This extension help me with a search from the Client table and it’s good when there are many records (a dropdownlist was impossible in my case).