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.

Passing HTML via hidden value field

  1. yellowhousedesign
    Member

    Hi all,
    I'm currently using the following function to pass a value to a hidden form field:

    add_filter('gform_field_value_inquiry_list', 'populate_inquiry_list');
    function populate_inquiry_list($value) {
    if(function_exists('upb_list_bookmarks')) {
    return upb_list_bookmarks();
    }
    }

    What this essentially does is return a function for the value of the inquiry_list parameter. If I set this as something as simple as:

    return 'test';

    it works just fine -- but since I am passing HTML data (which is what upb_list_bookmarks does) it doesn't seem to be saving the data at all - it's in-fact stopping the form from submitting. I've tested the function itself and it does return the information I want (again, an HTML ul>li list with URLs) and have even tested it by adding that to a sample textarea field, which works fine. It's this hidden field that I'm having trouble with. Do I need to somehow escape the HTML values for a hidden field? I'm ultimately looking for this form to be able to send the notification email to admins with that HTML list (which is generated per user). Any help would be greatly appreciated. Thanks!

    Posted 12 years ago on Friday May 11, 2012 | Permalink
  2. David Peralty

    Try to use the following function on your data first and see if that helps - http://php.net/manual/en/function.htmlspecialchars.php

    Posted 12 years ago on Friday May 11, 2012 | Permalink
  3. yellowhousedesign
    Member

    Hi David,
    Thanks for the link - unfortunately, nothing changed with that. This is what the output looks like (of that function):

    <ul class="upb-bookmarks-list"><li class="upb_bookmark bookmark-273"><a href="http://yhmags.com/wordpress/moulding-profiles/profile-1/" class="upb_bookmark_link" title="Profile 1">Profile 1</a> - <a href="#" class="upb_del_bookmark upb_del_bookmark_273" rel="273" title="Remove this Bookmark">Delete</a></li></ul>

    Posted 12 years ago on Friday May 11, 2012 | Permalink
  4. David Peralty

    Can you show me your functions.php code? The issue is that we are trying to put HTML inside HTML and of course it is breaking, but we should be able to change it so that it works, but I'm not exactly sure how yet as it is being outputted by another function/plugin.

    Posted 12 years ago on Friday May 11, 2012 | Permalink
  5. yellowhousedesign
    Member

    Hi David,
    The Gravity Forms filter I'm using is referenced in my original question (I'm actually using this inside of a plugin). More specifically, I'm using http://codecanyon.net/item/user-bookmarks-for-wordpress/544129 to store the list of bookmarks. Let me know if that clarifies things or if I'm just making things more difficult :) Thanks.

    Posted 12 years ago on Friday May 11, 2012 | Permalink
  6. yellowhousedesign
    Member

    Sorry - here it is with that PHP function:

    add_filter('gform_field_value_inquiry_list', 'populate_inquiry_list');
    function populate_inquiry_list($value) {
    	if(function_exists('upb_list_bookmarks')) {
    		return htmlspecialchars(upb_list_bookmarks(),ENT_QUOTES);
    	}
    }
    Posted 12 years ago on Friday May 11, 2012 | Permalink
  7. yellowhousedesign
    Member

    Hi David,
    Any other info you need? Thanks.

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  8. yellowhousedesign
    Member

    Just a little more clarification. Here is the physical HTML output I get when using htmlspecialchars: http://pastebin.com/ySuR1xAS

    So I'm thinking the actual HTML should be fine to store/send. When I try to send this data though, I get the following:

    ----------
    403 Forbidden
    You don't have permission to access /wordpress/product-inquiry/ on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    ----------

    Any help would be greatly appreciated. Thanks!

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  9. David Peralty

    I was asking around to see if any of the developers have any ideas. It looks like HTML is stripped for security reasons, but you can use a hook to help re-enable the use of tags.

    http://www.gravityhelp.com/documentation/page/Gform_allowable_tags

    If you return true, it will allow all tags.

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  10. yellowhousedesign
    Member

    Thanks, really appreciate it!

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  11. yellowhousedesign
    Member

    Hi David,
    So - that function definitely seems useful, just doesn't seem to be doing what it's advertised to do, unless I'm missing some type of priority setting. Here's what I have:

    add_filter("gform_allowable_tags_1", "allow_basic_tags");
    function allow_basic_tags($allowable_tags){
    	return '<p><a><strong><em><ul><li>';
    }
    add_filter('gform_field_value_inquiry_list', 'populate_inquiry_list');
    function populate_inquiry_list($value) {
    	if(function_exists('upb_list_bookmarks') && is_user_logged_in()) {
    		return htmlspecialchars(upb_list_bookmarks($delete_link=false),ENT_QUOTES);
    	}
    }

    So - I'm allowing the ul,li and a tags in the form (with a form ID of 1) and am then adding in that function -- but same result. Is a priority needed, or can you see anything else in the way? Thanks.

    Posted 12 years ago on Monday May 14, 2012 | Permalink
  12. Going to go ahead and handle this via the Priority Support ticket that was opened for this. Going to close this thread and we'll take care of it via that ticket.

    Posted 12 years ago on Monday May 14, 2012 | Permalink

This topic has been resolved and has been closed to new replies.