0

Drupal 8 does not use HTML button tag for creating buttons, it instead uses the input tag to create buttons. This works fine for most part, except for buttons which include an icon gets messed up by themes which replace the icons with a gradient. For example, Bootstrap theme will replace the button icon with gradient, that makes the button empty.

Is there a way to create a button via render array that will generate <button ...><img ... style button?

Alternatively, is there a way for a module to only use a twig template in special case, but not all the time.

Other ideas?

Update: May 7 2020.


I have filed a Drupal Core issue to support new render type for imagebutton, hopefully it will get some attention, as this can't really be solved in contrib space.

1

1 Answer 1

0

You can create a custom HTML tag like this:

return [
  '#type' => 'html_tag',
  '#tag' => 'button',
  '#value' => 'whatever value...',
];

Another solution is to render a custom theme that creates the button, like:

return [
  '#theme' => 'your_template',
];

You can read more about rendering custom templates here.

0

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.