2
  button_submit:
   '#prefix': '<div class="col-md-4 text-right">text<button>button text</button>'
   '#suffix': '</div>'
   '#value': Send
   '#type': submit

I have the code above in YAML form. When I edit the code, I see the button tag; when rendering, only the following markup is left.

<div class="col-md-4 text-right">
ALGOasd
<input id="edit-button-submit" class="button js-form-submit form-submit" type="submit" value="Send" name="op" data-drupal-selector="edit-button-submit">
</div>

It´s clear that I have some filter, but I can't find it out. I also tried putting a <button> in a container item, but the same thing happens.

Why does this happen? How can I fix it?

1 Answer 1

0

You need to include the #allowed_tags property which is applied to #markup, #prefix, and #suffix. (See: Pass raw html to #markup)

button_submit:
  '#prefix': '<div class="col-md-4 text-right">text<button>button text</button>'
  '#suffix': '</div>'
  '#value': Send
  '#type': submit
  '#allowed_tags':
    - div
    - button

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.