PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How To Creating A Form Field For Users To Paste HTML Code In

  1. Hello,

    I am enjoying using Gravity Forms but I need help.

    How do I create a form field where users can paste their YouTube embed code? I am using the HTML field but that is only displaying the text I am typing in. I need a box where users can paste in their YouTube embed codes so I can collect them.

    I appreciate any help you can offer.

    Best Regards,
    Mike B

    Posted 11 years ago on Saturday February 23, 2013 | Permalink
  2. You can use a plain text field to accept the input from the user, rather than an HTML field. Then, you can use that field in your post content template or post body.

    That is if your users will input the whole embed code. If you just want the video URL, we can do it differently. Still with a plain text field, but then you need to add the HTML to your post content template to embed that video, rather than displaying the text they just input.

    Posted 11 years ago on Sunday February 24, 2013 | Permalink
  3. erin814

    Hi, I'm trying to do the same thing as the OP. I have a form where users can drop in their YouTube/Vimeo embed code as iframes. It's being input into a custom content type so I've set it up as a custom field on the form. It seems to work okay but for some reason, when I'm in the Edit screen for that custom post type item, it has input an additional iframe tag into that field. I think it might have something to do with the way either the form or the theme is handling the html inputs.

    I don't see a setting for plain text on the form. Is the paragraph text the same as a plain text input?

    Posted 11 years ago on Monday March 4, 2013 | Permalink
  4. erin814

    I figured out what the problem was. The template my client is using is setting the textarea value equal to the embedded code which was causing weird output errors. Something like value="<iframe width="400" et etc></iframe>" so I took the input and escaped the html and switched the double quotes in the embed code to single quotes. $value = str_replace('"', '\'', $value); . That seems to have resolved my issue.

    Posted 11 years ago on Monday March 4, 2013 | Permalink
  5. Glad you figured that out. Thanks for the update.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink