• Resolved ianlusk

    (@ianlusk)


    Hi, Matt!

    I’ve run into an issue where calling the icon with “get_sub_field(‘icon’)” returns the string “null” when the field is left empty in the admin. I’ve resorted to using “get_sub_field(‘icon’) != ‘null’)” in my template so that this ‘null’ string isn’t displayed to my users when icons aren’t desired.

    This field was likely created in a v1.x.x of your plugin. I saw this referenced in another thread here in your support area, so I’m curious if that has something to do with the issue?

    I feel like some code is not functioning properly, as a “get_sub_field(‘icon’)” should return “false” if it is not set, instead of returning a string of ‘null’.

    Thanks for your great plugin, and your help on this issue! It’s not affecting my users directly now thanks to my patch, but I do need to find a proper permanent solution, whether that is a plugin update or a template change on my end if your plugin (or ACF) has changed how the “get_sub_field” functions.

    Best,
    Ian

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Matt Keys

    (@mattkeys)

    Hey Ian,

    Thanks for reporting the issue. I will check this out with the 1.x > 2.x bit in mind and see if I can recreate the issue in my development environment. I’ll let you know how it goes.

    Thanks,

    Matt

    Plugin Author Matt Keys

    (@mattkeys)

    Hey Ian, thanks again for reporting. I was able to reproduce the bug and verify that it was caused from fields created + saved in 1.x and then displayed with 2.x of this plugin.

    The way I handle ‘null’ fields has changed between the two versions and I missed this. There is an extra check now in 2.x to see if the field is null, and return a false value if so.

    Let me know if you run into any other issues.

    Thanks,

    Matt

    Thread Starter ianlusk

    (@ianlusk)

    Hey Matt,

    I can confirm that the latest update fixed my issue beautifully. Thanks for your quick turnaround on this fix!

    Best,
    Ian Lusk

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Empty icon objects return as ‘null’ when using “get_sub_field()”’ is closed to new replies.