n Drupal 8 - Forcing template twig in form element | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

in this article, I'll show you how to force template twig for your form element using $info['template'] 

 * @param $variables
 * @param $hook
 * @param $info
function mytheme_preprocess_form_element(&$variables, $hook, &$info)
  if (isset($variables['element']['#id'])) {
//    $id = $variables['element']['#id'];
//    $info['template'] = str_replace('_', '-', $hook) . '--' . $id;
    $info['template'] = 'form-element--edit-keys';

and then you should create form-element--edit-keys.html.twig file in your theme



Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook