Can gii CRUD tool create relations in the views?

Hi,

With Cake, when you have one to many or many to many relationships, the code generator will honour these relationships in the views, so that you can update, for example, one to many relationships "right out of the box", without the need for any additional coding. Is this possible in Yii with the Gii tool? If not, is it a planned feature for a future release?

Thanks,

PJ :)

If your using Gii and have your database files properly defined with foreign constraints, then yes, the relationships will be honored. However, you will not immediately see these in the view, but rather in the model. You can then access those relations anywhere you have a valid instance of that model - be it in the controller or view. And for further information I would like to add that typically you would instantiate the model in the controller and pass it to the view with the rendering methods. :D

Hope that helps you!

I’ve had no problem creating these relationships in the model. So my question was more specifically, can the CRUD tool (not the Model Gii tool) create these relationships in the views, for example by automatically adding a dropdown box for a one to many relationship.

Ah. Ok. Honestly, I don’t completely know. I wondered the same thing a while ago, but just never dug into the question much. From what I have seen and worked with though, right out of the box, No, Yii does not have the functionality. I used to use CakePHP though, and I must say that I am liking Yii more for a number of reasons. And creating dropdowns for those relations is a rather simple task by actually using the model on the view… but what you are asking, I would have to say No it does not and I am not sure if they will ever add that or not. Sorry. :-X