Is there any input that will $_POST the RTF correctly?

  • rpjostform1
    Asked on July 3, 2017 at 2:32 AM

    I have tried all of the JotForm inputs and widgets that allow for a user to enter RTF content.  However, the data sent via $_POST removes ALL formatting.  Is there any way to retain any HTML formatting sent via $_POST?

    1.  I know about PHP's nl2br() to add line breaks.  This is correctly adding <br> to the data.  But that seems to be the only formatting.

    2.  I cannot use the CK Editor Widget because I am also using the Preview Before Submit Widget.  Unfortunately, the PREVIEW widget does not 'see' the CK Editor's content.

     

    Thanks.

  • Nik_C
    Replied on July 3, 2017 at 4:16 AM

    1. Did you try using the Long text entry and switching to Rich text:

    Is there any input that will $ POST the RTF correctly? Image 1 Screenshot 30

    The data submitted retained the formatting I did:

    Is there any input that will $ POST the RTF correctly? Image 2 Screenshot 41

    Or the data is not preserved later on?

    2. That is true, a widget will not be shown in Preview before submit page.

    We'll wait for your response.

    Thank you!

  • rpjostform1
    Replied on July 3, 2017 at 7:07 PM

    Here's an example of what I mean...

    Using the Long Text input with the Rich Text selection...

     *Code below has been edited to allow you to see the tags (= I added white space)

    The original data entered was this:

    < strong > teaching< /strong > and < strong >research< /strong >

    Unfortunately, this was received as this:

    < span style="box-sizing: border-box;" >teaching< /span > and < span style="box-sizing: border-box;" >research< /span >

     

    Please test yourself to confirm.  I don't have any PHP coding that would remove HTML tags.  I'm using the same $_POST input code for all data.  Obviously, a plain ol' strong tag should make it through - but I guess not.

     

    P.S.: I must have the ability for my users to COPY/PASTE their code into my form... which is where the code above originated - from a website.

     

    Thanks.

  • Chriistian Jotform Support
    Replied on July 3, 2017 at 9:05 PM

    I tried to test the Long Text Entry field with Rich text selection on my end. The data I entered was:

    <strong>Test</strong>

     

    Is there any input that will $ POST the RTF correctly? Image 1 Screenshot 30

     

    And here's the result:

    Is there any input that will $ POST the RTF correctly? Image 2 Screenshot 41

     

    May we know the whole your PHP code so that we can further check it?

    We'll wait for your response.
    Regards.

     

  • rpjostform1
    Replied on July 4, 2017 at 1:15 AM

    How to reproduce this situation...

     

    1.  Use this form:

    https://form.jotform.us/71831084454153

     

    2.  for the BIO INFO entry data, go here:

    https://www.jhu.edu/about/

    *Why am I using this page?  This would be a typical "type" of webpage that one of my clients may use as a COPY/PASTE situation for their BIO info.  I researched the HTML in this page/section and it's vanilla.  I completely understand if an external CSS parameter would cause a style to occur.  That's not the case in this section.  All (= most) styles in this section are inline.

     

    3.  COPY/PASTE the middle main content of this ABOUT page:

    from... “What are we aiming...

    to... (PDF)

    4.  Enter/PASTE this section into the BIO INFO input

    5.  Complete the form and submit.

    6.  View the $_POST output data and you'll see that the < strong > tags:

    < strong > teaching< /strong > and < strong >research< /strong >

    are gone.  AND... if you "INSPECT" (using your browser's INSPECT feature in the page https://www.jotform.com/show-post-data/ ") the originally "< strong >" tagged words, you'll see that they are now tagged with:

    < span style="box-sizing: border-box;" >teaching< /span > and < span style="box-sizing: border-box;" >research< /span >

    It does seems as if other HTML tags are passing correctly.  Maybe this is specific to the "< strong >" tag. ??  Could there be other HTML tags that are not passing?  I haven't done extensive testing yet.

     

    Thanks for your help.

     

     

     

     

  • Chriistian Jotform Support
    Replied on July 4, 2017 at 3:16 AM

    Thanks for proving more info.

    I have tried to follow the steps you have provided to replicate the issue and I noticed that even before submitting the form, the HTML formatting <strong> tag is not being copied properly on the Long text entry with rich text when copying the text from the site (https://www.jhu.edu/about/) to your form. That's why after clicking the submit button, that will be the result also.

    Is there any input that will $ POST the RTF correctly? Image 1 Screenshot 40

     

    However, when I tried it with <b> tag, here's the result:

    Is there any input that will $ POST the RTF correctly? Image 2 Screenshot 51

     

    Result:

    Is there any input that will $ POST the RTF correctly? Image 3 Screenshot 62

     

    Could you please try it also on your end and see if this helps?

    If the issue still persists, please let us know.
    Regards.

  • rpjostform1
    Replied on July 5, 2017 at 3:11 PM

    Yep.  I did miss this.  So this issue is occurring at the point of the PASTE into the RTF Editor, correct?

    Is this an issue with the RTF editor or ??

    Any suggestions you have for a fix, a different method for the COPY/PASTE, or anything as a workaround are welcome.

    FYI:  I cannot use the CK Editor Widget as I am using the Preview Before Submit Widget which does not 'see' any input data from this widget (causing validation issues).

     

    Thanks.

  • Kevin Support Team Lead
    Replied on July 5, 2017 at 5:08 PM

    May we get a screenshot about how the information is posting on your end? 

    This is how I can see it on a cloned form of yours: 

    Is there any input that will $ POST the RTF correctly? Image 1 Screenshot 20

    This guide will help you uploading the image with your next reply: How-to-Post-Screenshots-to-Our-Support-Forum

    Regarding the conflict between the CKEditor and the Preview Before Submit widgets, I could replicate it on my end, this seems an issue, but we will assist you on a different thread. 

    https://www.jotform.com/answers/1191920 

     

  • rpjostform1
    Replied on July 6, 2017 at 4:38 AM

    Kevin_G:

    Please review a previous post in this thread:  Answered by rpjostform1 on July 04, 2017 at 01:15 AM

    I have the "  < span > " that is being improperly entered into the RTF editor detailed in this message.  If you follow the instructions on how to reproduce this error  you will experience this issue.

    You can see that the followup post from a JF Support tech confirms that ... for some reason, when performing a COPY/PASTE into the ' Long Text Input ' with the RICH TEXT selection, the < strong > tag changes to the < span > stuff.

     

    Thanks.

  • Chriistian Jotform Support
    Replied on July 6, 2017 at 5:30 AM

    It seems there is no issue with the Long Entry Text field (with Rich text selection) in the form since HTML formatting is being retained when submitting the form as we test it on our end. The only way to keep it working is to not Copy a text and paste it into the RTF editor, instead, do the editing of the texts directly to the RTF editor.

    Is there any input that will $ POST the RTF correctly? Image 1 Screenshot 20

    Regards.

  • rpjostform1
    Replied on July 6, 2017 at 2:57 PM

    Yep.  Thats what I thought your response was going to be.  The "COPY/PASTE" functionality is simply not going to happen 100% of the time.

    Or, at the very least... the user can choose to COPY/PASTE their content into the RTF editor ... but then, they need to carefully review the content to find the sections that have not been properly formatted.  .. and that's it, correct?

  • Kevin Support Team Lead
    Replied on July 6, 2017 at 3:33 PM

    Yes, that is correct, it's recommended to format the text directly using the tool. I have further tested and found the reason why this happens. 

    The rich text editor will recognize the format if it has been applied using HTML tags, an example would be: 

    <p>

    <i>

    <b>

    <u>

    Text 2

    </u>

    </b>

    </i>

    </p>

    But, if the style has been applied using CSS codes (which seems to be the case with the text you are trying to copy and paste) then it will not be saved when the form is submitted, example, the text is displayed only using the HTML, but styled using CSS: 

    <p>Text 1</p>

    You can easily see the behavior with the following example: https://shots.jotform.com/kevin/Content/Samples/1189768/ 

    "Text 1" has been formatted using CSS while "Text 2" has been formatted using HTML tags, if you copy the first text it will not show the format on the POST data, but the second text will do. 

    In other words all the text would need to be formatted using HTML tags, which will not be always the case. 

    You could add the recommendation on your form, to suggest your users to format the text using the editor will help you to always keep the text as desired. 

    Hope this information helps. 

     

  • rpjostform1
    Replied on July 6, 2017 at 3:58 PM

    THANK YOU!!