el-cms / superBake

superBake repository for CakePHP 2.3.x
Other
12 stars 2 forks source link

Problem with models relation in generated plugins #20

Closed mtancoigne closed 10 years ago

mtancoigne commented 10 years ago

When fetching data for related models, an error is thrown:

Error: Call to a member function find() on a non-object

mtancoigne commented 10 years ago

This error occurs for tables with parent_id: when controller is generated, it throws the error.

I tested with bake and a scaffold controller and it works. Complete controller baking does not work too, so I guess the problem comes from cake.

mtancoigne commented 10 years ago

The problem was the following : in generated controllers, I defined a $uses var with current model. If model was linked to other ones (hasMany, hasOne,...) the controller was unable to fetch the data. Now, the controller have a $uses=null var if current controller has no model linked to it, and nothing if any.