3 Replies Latest reply: Jul 15, 2014 7:33 AM by fac586 RSS

    Line breaks being replaced by <br> tags in display only field

    Luis Cabral

      Hi,

       

      In Apex 4.2.4 I have a display only field with this content:

       

      <p>Line 1

      <p>Line 2

       

      Note that there is a line break between these lines.

       

      This field is rendered on the page like this (with escape special chars = NO):

       

      <p>Line 1

      <br>

      <p>Line 2

       

      Obviously this messes up the layout. The same thing happens if you have a rich text editor field with is conditionally rendered as read only.

       

      Is this a known bug?

       

      As a workaround, I am explicitly removing all chr(10) and chr(13) from the field when the page loads (far from ideal...)

       

      Thanks

      Luis

        • 1. Re: Line breaks being replaced by <br> tags in display only field
          fac586

          Luis Cabral wrote:

           

          Hi,

           

          In Apex 4.2.4 I have a display only field with this content:

           

          <p>Line 1

          <p>Line 2

           

          Note that there is a line break between these lines.

           

          This field is rendered on the page like this (with escape special chars = NO):

           

          <p>Line 1

          <br>

          <p>Line 2

           

          Obviously this messes up the layout. The same thing happens if you have a rich text editor field with is conditionally rendered as read only.

           

          Is this a known bug?

          No, it's a less well-known feature.

           

           

          Set the Show Line Breaks property in the item Settings section to No.

          • 2. Re: Line breaks being replaced by <br> tags in display only field
            Luis Cabral

            Thanks fac, your answer is correct... for display only items!

             

            However I could not find this setting for the rich text editor item type, which insists in showing line breaks as <br> when in read-only mode.

             

            For the time being, instead of conditionally showing the RTE item read-only or not, I have both a RTE and a display item and show/hide them accordingly -- at least I don't have to manually remove the line breaks from the display only field anymore.

             

            I didn't mark your answer as correct because of this pending issue.

             

            Cheers

            Luis

            • 3. Re: Line breaks being replaced by <br> tags in display only field
              fac586

              Luis Cabral wrote:

               

              Thanks fac, your answer is correct... for display only items!

               

              However I could not find this setting for the rich text editor item type, which insists in showing line breaks as <br> when in read-only mode.

               

              For the time being, instead of conditionally showing the RTE item read-only or not, I have both a RTE and a display item and show/hide them accordingly -- at least I don't have to manually remove the line breaks from the display only field anymore.

              Another workaround that avoids duplicating the control is to use CSS to suppress display of br elements occurring immediately after paragraphs in display-only elements. Add the following to the Inline CSS property on the page, or create an external style sheet to apply this across multiple pages:

               

              .display_only p+br {
                display: none;
              }
              

               

              You can tweak the selectors to apply only to specific controls or regions etc.