CRUD generated relationships with gii

I’ve just started to play with yii (I come from ZF). I’m trying to generate CRUD forms. Some of my tables have relations (1-N and N-N). When I try to generate CRUD forms with gii, all form fields are generated as text inputs.

Is there something I can change to automatically generate select boxes for foreign key fields?

If this is not possible, what’s the best practice to generate this select boxes? I don’t know if modify _form.php manually for each model is a good practice.

Gii doesn´t support this. You have to it on your own.

Some examples:

Thank you very much. I’ve read compliments about yii forums but this was really fast!

All these examples use queries at view level. Is this a good practice or is better to query model in controller (create action) and use a variable to communicate with view?

  • I’ve edited your quote because I’m not allowed to quote links >-<

If queries become more complex or should be reused I would put them into the model as a function getXXXXXdata for example.

I’ve put this query code at controller and pass the result to the view through a variable. I don’t like very much to query model form a view :stuck_out_tongue: