0

I need to add extra CSS styles for a set of fields in the node add page for the jobs content type, but I don't know what template file should I use. I enabled Twig debugging, and I tried the following options.

  • page--node--add--jobs.html.twig, but it shows all regions

  • hook_theme(), but the custom template is not getting applied

My code for hook_theme() is the following.

 function custom_module_theme() {
  //  dpm("node:".drupal_get_path('module', 'comp_jobs'));  
  return [
    'node-jobs-form' => [
      'render element' => 'form',
      'template' => 'jobs',
      'path' => drupal_get_path('module', 'comp_jobs') . '/templates',
    ],
  ];
}

What template file should I use, and how do I tell Drupal to use that?

1 Answer 1

0

The template for the node add form is node-edit-form.html.twig. But adding attributes to form fields is not an easy task in twig. You probably are able to do this more efficient in a form alter hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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