Friday, April 24, 2009

A text-field with formatting

Sometimes, you want your text-field (meaning "field" in an Archetypes context) to preserve line breaks. I used to think this was not possible: if you want line breaks, or other formatting stuff, you'll have to use a rich text field.

However, my colleague Huub pointed out this neat way of preserving formatting in a text field:

You set the tagged values:
default_content_type=text/x-web-intelligent
allowable_content_types=python:text/x-web-intelligent
default_output_type=text/html


This will even turn e-mail addresses and urls into links.

No comments: