I used CCK to add fields to a custom content type. Even though all those fields are set to 'filtered html', and when adding content I checked that each field is rich text and full or filtered html, if I use any html tags when adding content (bold or even paragraph or line breaks), the page won't save (returns the 403 error page).

If I delete all my tags, basically making everything a long, run-on paragraph, I can save my content. Then I can go back and add the tags and it seems to save fine. Not an acceptable solution in long run.

I've tested with other content types, created new fields, but always get the same result...something as silly as using the enter key in a CCK field while adding text means the page doesn't save.

>>Using Drupal 6

CommentFileSizeAuthor
#1 ckk-html.PNG25.36 KBzeroagain

Comments

zeroagain’s picture

Status: Active » Closed (fixed)
StatusFileSize
new25.36 KB

You may use Custom Formatters module if you wish to use HTML tags in fields created by CCK module.

dhills’s picture

I have already the option to use full or filtered html. I have tried using both settings, but either way, when I first add content to my content type, I cannot save the page if any of the fields I fill in contain other than one line of plain text. Even pressing enter for a line break will make the page not save and return a 403/404 page. It will accept absolutely no markup at all. That especially sucks since some of the fields could have default text since they are always the same, but because the default text has more than one paragraph (uses a line or paragraph break), I get the same error.

BrianLewisDesign’s picture

Issue summary: View changes

Raw HTML CCK Field (Drupal 6) - no filters, formats or editor

Simple Fix for Drupal 6! Just use plain text format. Then convert it back to html in a field .tpl when the node is built.

Plain Text format on a CCK field will convert the HTML tags to entity special characters (this would make is so it reads like code on the page instead of being actual html tags). It stores the string encoded using php's htmlspecialchars($text, ENT_QUOTES, 'UTF-8') inside of drupal's check_plain() function.

The cleanest simplest way to decode it, is in a field tpl file. This avoids hooks, hook order problems, looping bugs, and performance issues. This is done by adding tpl files to the base themes: hq_base, odyssey_base and odyssey_admin. Here is how drupal decodes plain text on a cck node edit form: print html_entity_decode(strip_tags($text), ENT_QUOTES); Note - html_entity_decode turns php tags into html comments when it decodes back to html. Here are sample files with the correct naming convention to give php control over the fields:
• content-field.tpl.php
• content-field-[your_field_name].tpl.php

content-field.tpl.php is a copy from the cck contrib into the theme folders, this is a contrib override to make it available in the theme, and should not be modified (unless you wanted to change all the fields in the theme). The field specific file is also a copy of the tpl, it will work once the override file is there. Then decode to html in the field tpl file:
• // print $item['view'];
• print html_entity_decode(strip_tags($item['view']), ENT_QUOTES);

Drupal Version Note:
The tpl files are slightly different in Drupal 7 and Drupal 8. But the html_entity_decode() is a php function that won't change per Drupal version.

Security Note:
This decode trick for getting raw HTML goes against the way Drupal was built for text formatting security. It means that anyone with permissions to edit the page now has permissions to edit html structure, and add script tags on the page. This can break layouts, and potentially be dangerous. You are relying on editing permissions for security here, instead of Drupal's normal Formats-per-Role security.