I've created a custom text format I'm trying to apply to a field programmatically. As best I can tell, the format IS getting applied, but it is not stripping HTML tags like it is supposed to. The below screenshot shows how my text formatter is configured:

enter image description here

As you can see, its supposed to filter <span> tags. The Nodes where this will be used get created programmatically, and I apply the text formatter as follows:

'field_career_job_description1' => ['value' => $job['jobdesc'],'format' => 'careers_html_formatter']

This appears to be working correctly, if I print the variables passed to twig, I see that the formatter is, indeed, my custom format:

enter image description here

However, as you can see in the sshot, <span> tags are still in the text.

Note that I am displaying the field in question in Twig as follows:

{{ content.field_career_job_description1[0]['#text'] | raw }}

  • Kindly avoid pasting code as screenshots. This is bad for accessibility, discoverability and reproducing issues. Thanks!
    – alberto56
    Commented Mar 15, 2023 at 23:09

1 Answer 1


As I was pressing post on this question, I realized the problem. It's the twig code. In order to get the text formatter properly applied, I had to call my field as follows:

{{ content.field_career_job_description1 }}

Leaving this question up because I couldn't find anything like it on google


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.