Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

It seems to me that the markup inside of Salesforce richtext fields is somewhat stripped/trimmed when saving?

My code relies on the fact that an image has an multiline alt attribute (which is valid HTML. But whenever I save this fields record those multilines are removed.

Have you seen this before and how could I prevent this from happening? Use a long text field instead and output with outputText?

share|improve this question
    
If you control the attributes, could 
 get you going? –  user320 Jan 24 '13 at 22:53
add comment

3 Answers

Sadly I've tried a few things for you and I don't seem to be able to get this to work either. My conclusion and thus answer, agrees with your findings, newline characters in attributes are being stripped.

It appears as though a space is being replaced with any new line character/s.There is a lot of successful examples using text area, but not rich text area, by using \r\n. Anyway here is the code I was trying it out with in case you want to compare. Sorry I could not find a solution for you this time Robert.

Update: As per user31, I also tried &#13 and &#10 and combinations.

Update: The answer to this question goes someway to explain what I suspect is happening internally.

share|improve this answer
add comment

Markup put into these fields is cleansed internally I believe to provide as much protection as possible from XSS attacks which could be implemented through HTML in these fields which then gets inserted into the page on render.

If you need some way of indicating a line break I'd use a custom code of your own devising, something unlikely to appear int he alt-text otherwise, for example CRLF. You could then perform a search and replace after querying the field to put in whatever line breaks you need.

share|improve this answer
add comment
up vote 2 down vote accepted

I switched to long text fields and used my own richtext editor on them (CKEditor) and now it works. Long text fields work as a charm without the problems they imposed on RTF fields for security reasons.

Thanks for your answers.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.