What is the best way to define template name suggestions for children elements of form in drupal 8?
In myTheme.theme
I can define hook like this:
function myTheme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { if ($hook == 'form' & !empty($variables['element']['#id'])) { $suggestions[] = 'form__' . str_replace('-', '_', $variables['element'] ['#id']); } }
Which gives suggestions:
form--form-id.html.twig form.html.twig
I want to define template names for all elements inside my form with id of the form as part of name suggestion. For example:
form-element--form-id.html.twig form-element.html.twig