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.

Field_values not set when posting form

  1. I'm creating a form like so:
    [gravityform id="2" name="foo" field_values="a=b"]

    I've got a custom field which catches the value of 'a' in this case (having set the proper options to catch the value of course):

    add_action('gform_field_content', 'eo_add_field_schedule', 10, 5);
    function eo_add_field_schedule($content, $field, $value, $lead_id, $form_id)
    {
        if ($field['type'] == 'schedule') {
            var_dump($value);
        }
        return $content;
    }

    On page load, the dump correctly displays 'b' but when posting, the value remains empty. This issue pops up once the form has validation errors.

    Any idea's on this one? Thanks!

    Posted 13 years ago on Monday April 16, 2012 | Permalink
  2. I used your code snippet above on an email field and the $value variable had the right value after the form is submitted. After the form is submitted, the $value variable will have whatever was actually entered in the field, and not what was used to initially populate it.
    I am guessing in the dark, but I think the problem is your input does not have the right name attribute. (i.e name="input_FIELDID"). Take a look at the text field input and try making yours follow the same pattern. That should make Gravity Forms understand the value submitted by your input and the $value variable will then be populated with the value that was submitted.

    Posted 13 years ago on Tuesday April 17, 2012 | Permalink
  3. How obvious to set the right name attribute.. Thanks Alex! It even works with array values!

    Posted 13 years ago on Wednesday April 18, 2012 | Permalink
  4. David Peralty

    Glad it got sorted out.

    Posted 13 years ago on Wednesday April 18, 2012 | Permalink

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