PHP Forms

tmhenson's Avatar

tmhenson

03 Aug, 2012 01:39 PM

My forms are working great with the exception of the confirmation message will not show up when HTML tags are present in the WYSIWYG content box. I have narrowed it down to this piece of code:

elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
            print(htmlentities("$callingPageData.getChild('system-data-structure').getChild('confirmation_text').text"));
}

The 'confirmation_text' needs to be sent as HTML vs text.
How would I accomplish this?

  1. 1 Posted by Ryan Griffith on 03 Aug, 2012 02:07 PM

    Ryan Griffith's Avatar

    Hi tmhenson,

    Let's try using the $_EscapeTool and see if that helps:

    elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
                print("${_EscapeTool.html($callingPageData.getChild('system-data-structure').getChild('confirmation_text').value)}");
    }
    

    Note: using $_EscapeTool.html() should already convert the HTML to entities so I removed the htmlentities() call in your print statement.

  2. 2 Posted by tmhenson on 03 Aug, 2012 02:31 PM

    tmhenson's Avatar

    The text shows up now but it is stripping the HTML tags from the WYSIWYG now.

  3. 3 Posted by Ryan Griffith on 03 Aug, 2012 02:37 PM

    Ryan Griffith's Avatar

    Hm, let's try the $_SerializerTool instead:

    elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
                print("${_SerializerTool.serialize($callingPageData.getChild('system-data-structure').getChild('confirmation_text'), true)}");
    }
    
  4. 4 Posted by tmhenson on 03 Aug, 2012 03:20 PM

    tmhenson's Avatar

    The tags are rendered but it creates an error and the page will not load.
    I tried

    print(htmlentities("$callingPageData.getChild('system-data-structure').getChild('confirmation_text').value"));
    

    which sends the WYSIWYG as text not HTML either.

  5. 5 Posted by Ryan Griffith on 03 Aug, 2012 03:31 PM

    Ryan Griffith's Avatar

    Typically WYSIWYG content is outputted with the SerializerTool, I believe just using value would strip the HTML out.

    What was the error message you received with my previous suggestion?

    Maybe you could try outputting the HTML to the page and not converting it to a String in PHP (not sure if this will break anything though):

    elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
                ?>${_SerializerTool.serialize($callingPageData.getChild('system-data-structure').getChild('confirmation_text'), true)}<?php
    }
    
  6. 6 Posted by tmhenson on 03 Aug, 2012 03:49 PM

    tmhenson's Avatar
    print('${_SerializerTool.serialize($callingPageData.getChild('system-data-structure').getChild('confirmation_text'), true)}');
    

    I change the " to ' and it is pulling the HTML in but my links are not working

    This is what is the source code

           <?php }
            }
            elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
                          print('<p>Thank you!!</p>
    <p>For your submission!!</p>
    <p><a href="site://UNA Public/web/docs/l-number.pdf">testing links</a></p>');
            }
            
        else{ 
        ?>
    
  7. 7 Posted by Ryan Griffith on 03 Aug, 2012 05:52 PM

    Ryan Griffith's Avatar

    Hm, would you be able to paste your entire Format so I can have a look?

    For the quote escaping, you might be able to use:

    elseif ($_GET['submitted'] == 'true') {  //NO POST, FORM submitted SHOW confirmation
                print("${_EscapeTool.java($callingPageData.getChild('system-data-structure').getChild('confirmation_text').value)}");
    }
    

    The $_EscapeTool.java() method will escape your double-quotes and leave the single quotes alone.

  8. 8 Posted by Ryan Griffith on 03 Aug, 2012 06:06 PM

    Ryan Griffith's Avatar

    Can you try the following and see if the links are rewritten:

    Replace:

    print('${_SerializerTool.serialize($callingPageData.getChild('system-data-structure').getChild('confirmation_text'), true)}');
    

    With:

    ?>${_SerializerTool.serialize($callingPageData.getChild('system-data-structure').getChild('confirmation_text'), true)}<?php
    

    This will essentially do the same thing as the print('WYSIWYG CONTENT);

  9. 9 Posted by tmhenson on 03 Aug, 2012 06:41 PM

    tmhenson's Avatar

    That works thanks for the help.

  10. tmhenson closed this discussion on 03 Aug, 2012 06:42 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac