Support » Plugin: Gravity Forms - Update Post » Not working with List Field

  • Hi,

    I think that it is not working with the List Field. As in your function you are using $value = maybe_unserialize($value); and the value is not an array or a serialized string. It’s indeed stored like 23|23|23|232.
    I will try to change the code to create an array out of this and see if the list field is displayed properly. If it does I will let you know, so you can update the core of your plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • OK. Just hacked the code of the plugin. This makes it work. You should remove the list from the switch case and make it separate into this.

    case 'list':
              $value = !is_array($value) ? array($value) : $value;
              foreach ($field['choices'] as &$choice)
              $field['defaultValue'][$choice['text']] = $value[$i];

    So happy that I found this! Cant really get it to work..

    Is this still working for you semyou?

    I had a look at the GF documentation for the Field Object Property “defaultValue”.
    Doesn’t look like it applies to list fields..

    The only other way I can think of is using the Field Value filter but that just feels like a bad workaround..
    Any suggestions?

    Thank in advance!

    Hi David,

    Did you try my fix? Did you change the code of the plugin?

    Let me know.

    Yea, I tried it but could not get it to work.. I removed the list case from the switch and made it separate as per your instructions.

    The code runs without errors but nothing shows up in the list field.
    I think the array needs to be built in another way..
    It only adds the first row even if there’s say 3 rows saved in the post.

    If I “print_r” the final array inserted in the $field[‘defaultValue’] it looks like this:

    Array ([0] => Array([Column-1] => text-col1|text-col2 [Column-2] => ))

    Only the first row is added to the array and the values for both my columns are added to the first column :/

    Do you know how Gravity Forms is expecting the default value for the list field? Cant find it anywhere.. If I knew how GF is expecting the array I could most likely change how the array is being put together.

    Hi David,

    I have fixed the bug in the plugin to support lists. However, I included also removal of duplicates by deleting previous entries. Please check here. Let me know if you have questions.

    Cool @semyou!

    I had to find a workaround for my project at the time. Will look at implementing this instead when I have time.
    Thanks for the follow-up!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Not working with List Field’ is closed to new replies.