When we enter properly formatted HTML into the RTE via the CP, the <p>
tags are present. But when we use the {exp:channel:form ...}
we lose all the <p>
tags but retain all other tags. We're using Textarea (Rich Text)
fields because we need the RTE on our custom dashboard.
I tested the {exp:channel:entries ...}
and the <p>
tags were properly retained.
So what could be causing this? How can we fix it? We need the channel form to output the proper tags because we have a live preview of what's in the populated textarea
elements.
Update:
When using {field:my_channel_field}
the <p>
tags are retained, but the RTE isn't created. It's just a textarea
with html/text.
Update 2:
I did some digging and found that in the SQL tables there are no <p>
tags, meaning that they're inserted when the data is called.
For instance this is what's actually in the Database
<h3>Lorem nascetur </h3> Porttitor. Integer nunc. Hac ultricies velit magnis. Nunc est, tortor proin?
And this what is output when using {exp:channel:entries ...}
:
<h3>Lorem nascetur </h3>
<p> Porttitor. Integer nunc. Hac ultricies velit magnis. Nunc est, tortor proin?</p>
So at some point the <p>
tags are being injected into the document, and I want to know how can I force this so they are in the RTE when the user goes to edit them within an {exp:channel:form ...}
loop?
Update 3:
I found these in /system/expressionengine/modules/rte/libraries/Rte_lib.php
on lines 445 to 446
// Strip paragraph tags
$data = preg_replace("#<(/)?pre[^>]*?>#i", "<$1pre>", $data);
$data = preg_replace("#<p>|<p(?!re)[^>]*?".">|</p>#i", "", preg_replace("#<\/p><p(?!re)[^>]*?".">#i", "\n", $data));
and
if (stristr($str, '<p') !== FALSE)
{
$str = preg_replace("#<(/)?pre[^>]*?>#i", "<$1pre>", $str);
$str = preg_replace("#<p>|<p(?!re)[^>]*?".">|</p>#i", "", preg_replace("#<\/p><p(?!re)[^>]*?".">#i", "\n", $str));
}
in /system/expressionengine/libraries/EE_Typography.php
.
Commenting them out didn't seem to solve the problem
Update 4:
I tested my theory more completely by simply doing a {exp:channel:entries ...}
and {exp:channel:form ..}
on a blank template with nothing other than a field.
When output, the channel:form
actually outputs HTML tags (<h3>
from update 2 above) that never get rendered, and the channel:entries
outputs the correct HTML and does get rendered. See picture: