Support

Account

Home Forums Add-ons Options Page get_fields() not returning values for options panel

Solved

get_fields() not returning values for options panel

  • Hi ACF team,

    First of all, I want to say thank you so much for the awesomeness you’ve put into this product. I’ve purchased all but one of the addons and I love every moment of it. As a developer when I get the option to choose what is returned from an image field (URL, ID or object) a tear comes to my eye 🙂

    I am having a small issue with the get_fields() function when used in conjunction with options pages. I am just starting out with the plugin and haven’t looked in the source code, so I’m sorry I can’t be of more help. Here’s what’s going on.

    I have created a number of options to be shown in the options page. The options show up perfectly, they save their data just fine. When I use get_field() in the fronted the data is retrieved. However, if I use get_fields() I receive a list of fields without the values:
    http://cl.ly/image/3L2I223r3T1F

    As you can see, the bottom one for example (_options_test_option) is empty. If I retrieve it’s value only via get_field() everything is just fine.

    I am using the following code for printing out all the fields:

    echo '<pre>';
    print_r(get_fields('option') );
    echo '</pre>';

    I am using the following to retrieve the single value:

    echo get_field('test_option', 'option')

    Let me know if you need any more help troubleshooting this, or if I’m just being stupid 🙂

    Thanks,

    Daniel

  • Hi @danielpataki

    Thanks for the bug report.

    Looks like your entire array is blank, but it is interesting that the keys all have underscores before them. This means that the returned data is actually the field keys, not the field values.

    I’ll try to reproduce the issue, but it looks like all your reference fields don’t exist for the options page values… this is quite odd.

    I’ll do some testing and get back to you

    Thanks
    E

  • Hi Elliot,

    Thanks for that, I’ll try and dig into the source code as well a bit. I dont think I did anything special to create my fields. The documentation does say that get_fields will only return fields which do not start with an underscore, but as the key IS returned I assume the value should be as well.

    The odd issue is that everything works perfectly except this one function. I will try and make time to troubleshoot this myself, I’ll report back if I find anything.

    Thanks for the help!

    Daniel

  • Hi @danielpataki

    Thanks again for the bug report.
    I have found the issue and pushed an update to github.

    A new version of ACF will be out shortly including this fix.

    Thanks again.

    Cheers
    E

  • Hi Elliot,

    Thanks so much for your help, I’ll just grab it from Github then 🙂

    Thanks again, top notch product and top notch support!

    Daniel

  • Hi @danielpataki

    Cheers mate. Just released 4.3.1 and this fix is included.

    Thanks
    E

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘get_fields() not returning values for options panel’ is closed to new replies.