Custom gridfield Add new button component template folder

Silverstripe Version:
4.2.1

Question:

I’m writing a custom gridfield Add new button component. I have an error that the template can’t be found.

PHP Warning: None of the following templates could be found: GridFieldSiteTreeAddNewButton in themes "Array\n(\n [0] => silverstripe/admin:cms-forms\n [1] => $default\n)\n" in /var/www/oirlib-develop/silverstripe/vendor/silverstripe/framework/src/View/SSViewer.php on line 215, referer: http://dev.local/admin/pages/edit/show/6

I’ve tried putting the template files in various different directories, but I can’t seem to find the right place for CMS/admin templates.

Can anybody suggest where these template files should go?

Thanks!

hey @cmdrruborg,

Can you please elaborate more that in which file you put the code of gridfield button?

hi there. I basically made a copy of the GridFieldSiteTreeAddNewButton.ss that comes with Lumberjack. With some help from the slack channel, in the end, since I had removed the namespace, the place to put it was in app/templates/GridFieldSiteTreeAddNewButton.ss

Hi @cmdrruborg,

Try this hope it helps you,

Put that GridFieldSiteTreeAddNewButton.ss file into theme/your-theme/templates/Layout folder.