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.

Input on Single Line Text is cut off after

  1. On our form, the field "Query String From RemoteDongleUpdate program", the input needs to be limited to 16 characters and access all characters including "<". However, whenever the 16 character string includes "<", any characters after that are left out of the post.

    Form is seen here.
    http://www.salient.com/uxt-license-number-form/

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  2. What does your query string look like? Is it <12345678901234> or is there a > in there somewhere else? I am guessing the < and > look like HTML and are being stripped out, but I would like to try it out if I know what your input is. Thanks.

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  3. It can appear anywhere in the string.

    For example,
    If the string was Dn8D99^-5=l!S<2g, it would return as Dn8D99^-5=l!S.

    As soon as < shows up, it drops the rest.

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  4. I believe that's because it looks like HTML and is thus stripped out. It's not a proper HTML tag, so everything afterward is removed. I don't know if there's a way around that.

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  5. Right. That's what I was thinking.

    If you find a way please let me know.

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  6. I was wondering if there is a way to hash that, so it's not stripped out later, or if there is a filter you can remove. I haven't had a chance to look through the code yet to see when that's being stripped out, to know if we can get at the value beforehand.

    Posted 10 years ago on Friday October 21, 2011 | Permalink
  7. Where would I go to check the filters?

    Posted 10 years ago on Wednesday October 26, 2011 | Permalink
  8. Would it have to do with this chunk of code from gravityforms.js? Does < need to be added into the criteria somewhere?

    this.htmlDecode = function(text) {
            var c,m,d = text;
    
            // look for numerical entities "
            var arr=d.match(/&#[0-9]{1,5};/g);
    
            // if no matches found in string then skip
            if(arr!=null){
                for(var x=0;x<arr.length;x++){
                    m = arr[x];
                    c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character
                    // if its a valid number we can decode
                    if(c >= -32768 && c <= 65535){
                        // decode every single match within string
                        d = d.replace(m, String.fromCharCode(c));
                    }else{
                        d = d.replace(m, ""); //invalid so replace with nada
                    }
                }
            }
    Posted 10 years ago on Wednesday October 26, 2011 | Permalink
  9. @pstonier, I have a work around about 50% complete, storing the string in hexadecimal. Need to convert that back to ASCII before the notifications are sent, and when the value is displayed in the admin. Thanks for hanging in there. Did you try any other workarounds?

    Posted 10 years ago on Saturday October 29, 2011 | Permalink
  10. Thanks. Tried one small thing, but hardly worth mentioning.

    Posted 10 years ago on Monday October 31, 2011 | Permalink
  11. Gravity Forms v1.6, which is available as a development release and will be released to the public later today or tomorrow, has a new hook that let's you allow a field to accept HTML.

    By default we don't allow it because it's good security practice. BUT if you must enable it on a field, here is the hook you can use when using Gravity Forms v1.6:

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

    Posted 10 years ago on Monday October 31, 2011 | Permalink
  12. Thanks, Carl. I see that 1.6 was released for the Wordpress plugin. I upgraded through there.

    This may be a bit of a n00b question, but how do I apply a hook?

    Posted 10 years ago on Wednesday November 2, 2011 | Permalink
  13. Hi Pstonier,

    You can just add the example code form the documentation to your theme's functions.php and modify it from there. :)

    Posted 10 years ago on Wednesday November 2, 2011 | Permalink
  14. Thanks, guys, but that didn't quite do it.

    Now when I input "21782<wjk&*>/dwd",
    it returns "21782/dwd"

    and when I input "21782<wjk&9jjijk",
    it returns "21782"

    Posted 10 years ago on Wednesday November 2, 2011 | Permalink
  15. I thought that might happen with the HTML-looking markup since it's not well formed. I will finish up my solution and post it here. Thanks for hanging in there.

    Posted 10 years ago on Friday November 4, 2011 | Permalink
  16. How about this?

    Code:
    http://pastebin.com/G8JxeKp8

    Form export:
    http://min.us/mbkHjgAT43

    Screenshot - entries list:
    http://min.us/mcl6hI0WI

    Screenshot - single entry view:
    http://min.us/m5L7Ky8wF

    Please ask questions. I added comments but if something is unclear, please ask. Not covered here is the conversion of the value before notifications are sent.

    Posted 10 years ago on Friday November 4, 2011 | Permalink
  17. There are three functions in that code:

    1. Convert the value to hex before storing it
    2. Convert back to ASCII before showing the list of entries
    3. Convert back to ASCII on the single entry view
    Posted 10 years ago on Friday November 4, 2011 | Permalink
  18. I'm thinking that I must be applying the filter incorrectly.

    I did some further testing and it always worked like this…

    when I input "21782<wjk&*>/dwd",
    it returns "21782/dwd"

    and when I input "21782<wjk&9jjijk",
    it returns "21782"

    So the first filter didn't seem to affect anything either–therefore, I'm probably applying the filter incorrectly.

    The functions.php file that I'm pasting the code into is root/wp-content/themes/current_theme/functions.php. The only thing that I've been removing is the top <?php b/c dreamweaver shows a syntax error.

    The code for the functions.php file is here http://pastebin.com/bMx9g7rs

    Thanks again for your help. I appreciate it.

    Posted 10 years ago on Monday November 7, 2011 | Permalink
  19. It's OK to strip off the leading <?php so long as the code you paste in to functions.php is within PHP tags (and not stuck in the middle of another function by mistake.) If not, bad things will happen.

    You're putting the code in the correct file.

    Are you sure the field ID and form ID are both correct, on all lines? Mine was form 60 and field 4, and I see that in the code you pasted, but I doubt those are your values. They would need to be changed to match your form.

    Posted 10 years ago on Tuesday November 8, 2011 | Permalink
  20. Good catch! I missed that part.

    I'm close!
    It's converting to hexadecimal, but not converting back.

    dj21j<22j>djj<dk is returning this 646A32316A3C32326A3E646A6A3C646B

    The code I'm using is… (form id is 7 and input is 5)

    <?php
    
    // http://www.gravityhelp.com/forums/topic/input-on-single-line-text-is-cut-off-after
    // this handles converting the entered value to hex for storage
    //
    // strtohex and hextostr functions lifted from here:
    // http://www.php.net/manual/en/function.hexdec.php#100578
    //
    // gform_pre_submission_filter_7 <--- 7 for FORM ID 7
    add_filter('gform_pre_submission_filter_7', 'ch_strtohex');
    function ch_strtohex($form) {
    	// input 5 is the form field I want to convert to hex
    	$x = rgpost('input_5');
    	$s='';
    	// convert the submitted string to hex
    	foreach(str_split($x) as $c)
    		$s .= sprintf('%02X',ord($c));
    	// assign the hex value to the POST field
    	$_POST['input_5'] = $s;
    	// return the form
    	return $form;
    }
    
    // retrieve hex and convert before displaying in the admin: single entry view
    add_filter('gform_entry_field_value', 'ch_hextostr_single', 10, 4);
    function ch_hextostr_single($x, $field, $lead, $form) {
    	// run this code on form 7, field 5 only
    	// FORM ID 7, INPUT ID 5
    	if ($form['id'] == 7 && $field['id'] == 5) {
    		$s='';
    		foreach(explode("\n",trim(chunk_split($x,2))) as $h) {
    			$s .= chr(hexdec($h));
    		}
    		// prevent rendering anything that looks like HTML as HTML
    		return htmlspecialchars($s);
    	}
    	else {
    		// not (form 7 and field 5), return the original value
    		return $x;
    	}
    }
    
    // http://www.gravityhelp.com/forums/topic/input-on-single-line-text-is-cut-off-after
    // retrieve hex and convert before displaying in the admin: entry list view
    // note the different filter name here "entries"
    add_filter('gform_entries_field_value', 'ch_hextostr_list', 10, 3);
    function ch_hextostr_list($x, $form_id, $field_id) {
    	// run this code on form 7, field 5 only
    	// change to match your form values
    	if ($form_id == 7 && $field_id == 5) {
    		$s='';
    		foreach(explode("\n",trim(chunk_split($x,2))) as $h) {
    			$s .= chr(hexdec($h));
    		}
    		// prevent rendering anything that looks like HTML as HTML
    		return htmlspecialchars($s);
    	}
    	else {
    		// not (form 7 and field 5), return the original value
    		return $x;
    	}
    }

    Posted 10 years ago on Tuesday November 8, 2011 | Permalink
  21. Actually, never mind. It is working in the entry view. I was missing it in the email notification.

    How hard is it to add a filter for the email notification part?

    Posted 10 years ago on Tuesday November 8, 2011 | Permalink
  22. If it's going to be time consuming/difficult, we can work with this as is. The application that will read the email can be written to convert the hex back.

    Thanks again, guys. Chris, especially, you are a form superhero.

    Posted 10 years ago on Tuesday November 8, 2011 | Permalink
  23. I did mention that I did not cover converting it in the notification. It was a lot of work to get it to work here with three separate functions. Looking at it again with fresh eyes, it would probably not be too bad to change it in the notification. I didn't know if you sent it or needed to send it in the notification, so I didn't spend any time on it. I was happy to bring it this far :-)

    Posted 10 years ago on Wednesday November 9, 2011 | Permalink
  24. No worries. Sorry for missing that originally.

    This will work fine. Thank you so very much! I really appreciate your hard work.

    Posted 10 years ago on Wednesday November 9, 2011 | Permalink
  25. Great. I figured you'd need to do something with the data to convert it back, so if you are forwarding the notifications for processing, and can convert the value there, that's great. Glad we got that working.

    Posted 10 years ago on Wednesday November 9, 2011 | Permalink