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.

Validation problem with custom field

  1. Hello there,

    I added a new field using gform_field_input. This field output a facebook LIKE box.

    Everything works fine until the validation.

    The LIKE box disappear and I would like it to stay on the page.

    Could you please advice me on how I could fix this problem ?

    Here is my code for adding the new field :

    add_action("gform_field_input", "facebooklike_input", 10, 5);
    function facebooklike_input($input, $field, $value, $lead_id, $form_id){
    if($field["type"] == "facebook-like"){
    $input = '';
    if (sfc_is_fan()) { // Function developed by Simple Facebook Connect by Otto.
    $input .= 'You LIKE us on Facebook, your chances are doubled.';
    } else {
    $input .= 'To double your chance to win, LIKE us on Facebook.';
    return $input;
    add_filter("gform_add_field_buttons", "add_facebooklike_field");
    function add_facebooklike_field($field_groups){
    foreach($field_groups as $group){
    if($group["name"] == "advanced_fields"){
    $group["fields"][] = array("class"=>"button", "value" => "Facebook Like it !", "onclick" => "StartAddField('facebook-like');");
    return $field_groups;
    Posted 12 years ago on Monday November 14, 2011 | Permalink
  2. Any one with an idea on how I could fix that ?


    Posted 12 years ago on Tuesday November 15, 2011 | Permalink
  3. There was a small problem with your code when displaying the button in the admin. Following is the code with the fix:
    As far as the field disappearing after validation, I could not replicate it. Following is a screenshot of my form after failing validation. Note the text from your field is still there.

    Did I misunderstand the issue?

    Posted 12 years ago on Tuesday November 15, 2011 | Permalink
  4. Hi Alex,

    Thanks for your answer !

    In fact, my custom field will display a Facebook Like Box like here :

    My code for the custom field :

    The only problem is that after validation it seems that the Facebook Like Box which was containing an iFrame is now empty... I would like to understand why and find a way of fixing this issue.

    Your support is much appreciated.


    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  5. Update :

    When I use HTML5 / JS integration it doesn't work :

    $input = '<div class="fb-like-box" data-href="" data-width="292" data-height="150" data-show-faces="false" data-stream="false" data-header="false"></div>';

    But when I use pure iframe the validation process does not remove the like box :

    $input = '<iframe src="//" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;" allowTransparency="true"></iframe>';

    Any idea why ?

    Thanks again for the support.

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  6. It looks like the problem is related to AJAX being enabled in your form. When AJAX is enabled, some scripts may need to be re-initialized when the page is submitted. The HTML5/javascript integration probably falls under that scenario.
    What I recommend you do is simply disable AJAX for your form.

    Posted 12 years ago on Wednesday November 16, 2011 | Permalink
  7. Hi Alex,

    Me again ! Thanks again for the Pastie, it really helped me out.

    I have still a question regarding this :

    In the original pastie ( the first $input variable is empty !

    I can click my button "Facebook Like It !" in the admin and the custom field is displayed.

    If I change the value of my $input into something like this :

    The button "Facebook Like It !" in the admin doesn't work anymore.

    Do you have any idea why ?

    If I need to use it, I have to add the field with the value $input = ''; in my code then change the value of $input once the field is already into the form.

    Thanks again for your time and patience.


    Posted 12 years ago on Wednesday November 23, 2011 | Permalink
  8. Any ideas ? I tried to find out what wasn't good in my code but I can't...

    Any help would be much appreciated.

    Posted 12 years ago on Saturday November 26, 2011 | Permalink