Skip to main content
Category:

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

Search

Page Facebook