jpruizs jpruizs - 11 months ago 98
PHP Question

Cakephp 3.0 modify "add" Bake template

I am creating a new Theme within CakePHP to bake a couple of database tables. I have been able to run the bake command and also I have modified the index.ctp template file.
Now, I want to change the add template. The default "add" page shows a sidebar with some quick links to related tables and a form on the right column. I want to remove the links, change the styles and add some other stuff. However when I open the default add.ctp this is what I see:

echo $this->element('form');

And that's all.

How can I modify the elements of this page if that's the only available code?
Is there any other file I am missing?


Answer Source

You need to create a Bake Theme where you place your form.ctp file, you can copy the one from the Bake plugin and modify as you like:

Then you can run the bake command with your own theme:

bin/cake bake view Posts add --theme jpruizs

About the $this->element('form') thing. It is a View element:

So you just need to got to the Element folder inside the plugin Template folder and see what it does :)