Question

I'm new to CakePHP. I'm keen to use the scaffolding feature to quickly generate views, and then to use bake to generate views that I can edit.

I have created custom scaffold views in app/views/scaffolds so that my scaffolded views fit in with the layout of my application. Is there any way that, when I bake views, they are based on the custom scaffolding views I created, rather than on generic views as they seem to be?

Was it helpful?

Solution

I think you have your concepts a little bit mixed up here. It's really just a matter of clarifying the terms:

  • scaffolding is something you don't really want to use except as a quick way to view data. Generally you won't edit these -- if you want to edit scaffolding, just do a bake and edit the normal views.
  • baking views - these take the templates from cake/libs and copy them over to app/views. Nothing too complex going on there, but when you want to edit the scaffolding, you do this.

So for your issue, you can probably just (temporarily) replace the files in cake/libs/view/scaffolds. I would also suggest that you replace the original scaffolding at that point, as its generally a bad practice to modify the files in the cake/ directory.

At that point, you should have the views that you want, all ready to go in your app/views directory. I would suggest from now on that you bake before you modify, so that you can just modify the views rather than having to deal with the process above.

OTHER TIPS

maybe you might want to try puting more css rules since when scaffolds, the generated view code is usually in a <div class='model'>.

I found this page in the cakephp cookbook which explains how to edit the view templates so that baked views produce custom HTML. At least in cakephp 1.2, the view templates are copied from app/vendors/shells/templates/views (to app/views).

http://book.cakephp.org/view/789/Modify-default-HTML-produced-by-baked-templates

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top