Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Overwrite field.html.twig

Started by Muut Archive 10 years ago · 4 replies · 370 views
10 years ago

Hi,

I have been playing with the form plugin, and didn't like the way it structured the fields in the form, hence I tried to overwrite them. First I just replaced the field.html.twig/form.html.twig in the plugin, but noticed that that didn't really work very well.. taking into account updates etc.

After that I decided to place the files i wanted to overwrite in the templates folder as that seems a better way (my understanding is that grav will always first look there anyway).

Problem I face now is that for my contact form the new field.html.twig works like a charm. Unfortunately this also overwrites the fields used in the admin panel.

Is there anyway to overwrite the field.html.twig file used in the form plugin for 1 theme specifically? Or at least tell the admin plugin to use the default twig template found in the form plugin folder?

10 years ago

Yes, put the customized files in user/themes/yourtheme/templates/forms/, they will be overridden only in the frontend.

10 years ago

Okay, thanks.. will play around a bit more.. what you suggest is the setup i have now, but still my form fields in the admin section look different than they used to. I did a clean install of the form plugin to make sure, and still the admin form fields remain the same (aka.. they look like the fields in my contact form)

10 years ago

I just figured out the problem.. In case anyone else stumbles across this note that apparently using CSP headers breaks the admin plugin.. seems i should either whitelist a couple of resources that are used, or allow 'unsafe-eval' or 'unsafe-inline' depending on what is used in the plugin..

10 years ago

Post this as an issue on the Admin Plugin repo on github, with some details, so we don't lose track of it.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1352 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4064 9 years ago
Archive · by Muut Archive, 9 years ago
1 2949 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago