1

I have a custom content type named called "circular". For Admin user the "circular" node add form is opening using administration theme (i.e. Seven). But for Authenticated user the node add form is opening using my custom theme. I want to override template of the node add/edit form the custom theme.

I created page--node--add.html.twig in the template folder of the custom theme and used {{ form }} to render the form. But blank page is coming.

How do I fix this?

0

This template will be used when a node edit form specifies 'node_edit_form' as its #theme callback. Otherwise, by default, node add/edit forms will be themed by form.html.twig.

Try this on your theme:

use Drupal\Core\Form\FormStateInterface;

function YOURTHEME_form_node_form_alter(&$form, FormStateInterface $form_state) {
  $form['#theme'] = ['node_edit_form'];
}

After this your theme can read template node-edit-form.html.twig.

https://api.drupal.org/api/drupal/core%21themes%21classy%21templates%21content-edit%21node-edit-form.html.twig/8.2.x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.