Custom gridfield Add new button component template folder

templates
silverstripe-4
Tags: #<Tag:0x00007f0827fdd9b0> #<Tag:0x00007f0827fdd6b8>

#1

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!


#2

hey @cmdrruborg,

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


#3

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


#4

Hi @cmdrruborg,

Try this hope it helps you,

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