Search code examples
phpdrupaldrupal-9

Drupal PHP field stripping HTML tags


This is Drupal 9 specific PHP issue: so bear with me.

I have several fields in Drupal field which are stored as RAW HTML, in Drupal terms which are called - Fields and the Values are stored - in field definition formatted html.

Problem : During re-edit, editor/edit screen pulls stripped html. HTML imported are strpped off HTML tags and HTML classes. And when re-edited post is saved the stripped html is getting stored(Overwritten)

This is causing serious issues for my site, cause this is a required feature. And some of my website-structue is depends upon the RAW HTML.

This could be PHP specific issue. If someone has experience regarding this, and how to get away with this - would be a help.

I need to get away with this, this is causing serious troubles with my Website Structure.

Description : Original HTML

<ul class="nav flex-column pl-0">

<li class="nav-head">Xamarin</li>

<li class="nav-item"><a class="nav-link" href="#">Overview</a></li>
<li class="nav-item"><a class="nav-link active" href="#">Analytics</a></li>
<li class="nav-item"><a class="nav-link" href="#">Export</a></li>
<li class="nav-item"><a class="nav-link" href="#">Snippets</a></li>
<li class="nav-item"><a class="nav-link" href="#">Flexbox</a></li>

<li class="nav-header">Xamarin Installation</li>

<li class="nav-item"><a class="nav-link" href="#">Layouts</a></li>
<li class="nav-item"><a class="nav-link" href="#">Templates</a></li>
<li class="nav-item"><a class="nav-link" href="#">Themes</a></li>

</ul>

When input through text-formatted-long HTML-input

When imported - During re-edit the formatted-field is striping html tags, and does not pull full html. imported-stripped-html

**For post visibility, I have posted the same issue, in several forums. So, this is not spammy qusetion, genuine development question


Solution

  • Choose Text format as Full HTML, your HTML will not be stripped anymore. enter image description here

    Update:

    It seems that your use of module Gutenberg did not display the Text format options. So, install the module Allowed Formats then enable the format Full HTML for your field.