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.

Getting nl2br warning when submitting form

  1. I'm using the Directory addon with Gravity Forms and receive this warning message on the page after hitting submit:

    Warning: nl2br() expects parameter 1 to be string, array given in /home/pidesign/www/www/clients/sailpdx/wp-content/plugins/gravityforms/common.php on line 3796

    I get this warning 16 times. The data is successfully recorded though.

    Any ideas?

    Posted 13 years ago on Tuesday February 14, 2012 | Permalink
  2. Hi, pidesign,

    I have seen this before but cannot reproduce the issue right now. Can you send me an export of your form with all its fields so I can reproduce the issue? You can email the form export file to me at "dana@rocketgenius.com". Please reference this post.

    Thanks.

    Posted 13 years ago on Thursday February 16, 2012 | Permalink
  3. I've posted this a couple of times, however, there are times when an Array is passed to nl2br. This is the case in GFCommon::get_lead_field_display.

    There is no case branch for every field. Add a hidden product field to your form to see this in action. Since there is no branch for hiddenproduct, but the hiddenproduct value is an Array not a string, it'll generate warnings.

    Since there are many calls to nl2br, I would recommend refactoring into a GFCommon::nl2br function where you can then check the value before passing an invalid value to the PHP nl2br function.

    Posted 13 years ago on Friday February 17, 2012 | Permalink
  4. Hi, oceancountycoll,

    I knew an array was being passed, just didn't know which field combination was causing the issue so I could reproduce it. Thanks for the info.

    Posted 13 years ago on Friday February 17, 2012 | Permalink

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