Support

Account

Home Forums Bug Reports Illegal string offset 'acf_fc_layout' on Flexible Content

Solving

Illegal string offset 'acf_fc_layout' on Flexible Content

  • I am using my own flexible content field and I filter it from another select field that is registered to an option page. The is basically a Global Blocks page. The fields are working great within the Admin panel and with in the front end of my website, but because of this I am getting this PHP Warning.

    Illegal string offset 'acf_fc_layout' in /var/www/shopbedmart/public_html/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-flexible-content.php on line 833

    Looking at the file and code there is a condition after the variable to check if it exists and if not then continue:

    class-acf-field-flexible-content.php on line 833

    
    // get layout name
    $l = $value[ $i ]['acf_fc_layout'];
    
    // bail early if layout deosnt exist
    if( empty($layouts[ $l ]) ) continue;
    

    In order to get rid of the Warnings which are flooding my log file I think an additional condition should be placed before the $l variable.
    Like

    
    if (empty($value[ $i ]['acf_fc_layout'])) continue;
    
    // get layout name
    $l = $value[ $i ]['acf_fc_layout'];
    
    // bail early if layout deosnt exist
    if( empty($layouts[ $l ]) ) continue;
    

    Thanks

  • Hi, have you found out what is causing this issue?

  • @bmostrey Sorry, No.
    I will add my condition above and it works, but I have to remember to add it back on each update.

  • This is not a bug that I have seen. Most of the time these errors are caused by how something else is being done. I would need more information, like more details on how you are constructing this flex field and template code being run when the error happens.

    You can also try contacting the developer, but he’d need the same information to try to recreate the error. https://www.advancedcustomfields.com/contact/

  • @hube2 Thanks,
    If I get time I will do that. Unfortunately, I am no longer on that project and a bit slammed right now, but I will keep it in mind.

    @bmostrey Just curious were you experiencing the same issue.
    If so, are you doing the same with Flexible fields that I am or something different.
    Thanks

  • @ggedde @hube2 Thanks for the help everyone, the issue was resolved the day after. If I’m not mistaken I had two fields with the same name which were causing this issue on the frontend (no error on the backend which I found confusing).

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

You must be logged in to reply to this topic.