jpruizs jpruizs - 2 months ago 22
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?

Thanks

Answer

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:

http://book.cakephp.org/3.0/en/bake/development.html#creating-a-bake-theme

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:

http://book.cakephp.org/3.0/en/views.html#elements

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