0

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 }}

0

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

  • Glad you found the answer - but you should accept it, even if it's your own. – Alfred Armstrong Sep 16 at 16:48

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.