Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Henrik Madsen 9 posts 29 karma points
    Feb 02, 2011 @ 13:12
    Henrik Madsen
    0

    TextArea formatting

    Hey..

    I have a textarea field in a form. I want to save the formatting for the text that is typed. Is this possible?

     

     

     

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Feb 02, 2011 @ 14:43
    Sebastiaan Janssen
    0

    The formatting is saved automatically (they are just newlines). 

    I am assuming that you want to send an html email with the newlines converted to <br /> tags. In that case you should use the "Send xslt transformed email" workflow item and create an XSLT extension that can convert the newlines to <br /> tags. XSLT extensions are usable in contour as well, here's mine:

        public class Strings
        {
            public static string ReplaceNewLinesWithHtmlBreak(string text)
            {
                return text.Replace("\n", "<br />");
            }
         }

     

     

  • Henrik Madsen 9 posts 29 karma points
    Feb 02, 2011 @ 15:31
    Henrik Madsen
    0

    Hmm. I'm making a comment function. The comment is the text typed in the textarea, which I want to be displayed with the right formatting.

    I tryed to replace \n with <br /> but there aren't any \n in the entity saved from the form. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 02, 2011 @ 15:33
    Jan Skovgaard
    0

    Hi Henrik

    The \n entities are not visible but occur everytime you make a new line using enter.

    So are you saying that there is not <br /> in your HTML code after the replace has been made?

    /Jan

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Feb 02, 2011 @ 15:37
    Sebastiaan Janssen
    0

    Must be a problem with you replace function, there's definitely newlines in the save forms. Just click on the edit button for a form entry and see the text in the textarea still has the proper line breaks in there.

  • Henrik Madsen 9 posts 29 karma points
    Feb 02, 2011 @ 15:48
    Henrik Madsen
    0

    Yes thats right. And i hit enter many times when I made the comment

    I tryed to replace all the 'g' instead to see if the worked. When I do that all the g's gets replaced with <br /> but it doesn't work as an html tag, it is just shown as text.

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Feb 02, 2011 @ 15:54
    Sebastiaan Janssen
    0

    Ah, you need to disable output escaping:

    <xsl:value-of select="someField" disable-output-escaping="yes" />
  • Henrik Madsen 9 posts 29 karma points
    Feb 02, 2011 @ 16:03
    Henrik Madsen
    0

    Thanks <br /> tag works now when I replace with 'g' but nothing happens when I try to replace with "\n"

    This is what I do. I didn't make my own replace function.

          <xsl:variable name="sss" select=".//fields/indlæg//value"/>
          <p>
            <xsl:value-of select="Exslt.ExsltStrings:replace($sss, '\n', '&lt;br />')" disable-output-escaping="yes"/>

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Feb 02, 2011 @ 16:21
    Sebastiaan Janssen
    0

    Just figured out that you should be able to do it quite easily like so:

    <xsl:value-of select="umbraco.library:ReplaceLineBreaks($sss)" disable-output-escaping="yes"/>
  • Henrik Madsen 9 posts 29 karma points
    Feb 02, 2011 @ 17:10
    Henrik Madsen
    0

    Thank you :) It works

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies