Home Forums Add-ons Flexible Content Field Undefined index of name in flex modules


Undefined index of name in flex modules

  • Hey,

    I am getting this error and I do not get the point why this error comes. The error comes from the code below and is located in class-acf-field-flexible-content.php. I added a screenshot of the error to this issue.

    // bail ealry if no name (tab)
    if( acf_is_empty($sub_field['name']) ) continue;

    Thanks in advance for thinking along for a solution

  • because you’re trying to pass $sub_field['name'] to a function. The variable, or in this case, the index, must exist to do what you’re trying.

  • Hello John,

    This is part of the acf plugin. I added the file where this happens it is on line 766.

  • <?php
    if( ! class_exists('acf_field_flexible_content') ) :
    class acf_field_flexible_content extends acf_field {
    				// bail ealry if no name (tab)
    				if( acf_is_empty($sub_field['name']) ) continue;
  • You’ve lost me.

    You are calling an ACF function that tests if a value is set. This function requires a value to be passed. This issue is that $sub_field['name'] is undefined were you are referencing it. This is PHP issuing the warning on your call. You can surpress this error by doing


    However, I don’t understand why you’re calling an ACF function when you could simply do

    if (empty($sub_field['name']))
  • I am not using this function.The code that breaks is part of the advanced custom fields plugin. I understand what goes wrong but i do not know how to fix it in my site if it the error is in the plugin. To be honest, I don’t see the added value of the function acf_is_empty.

  • Ahh, I finally see. Sorry, I somehow got it into my head that it was code you were using. What version of ACF are you using?

  • I first saw it on version 5.8.6 but I updated it to 5.8.7.

  • I am using that version and not seeing this issue. Are you defining any fields in the flex field using php? All fields should have the ‘name’ index event when they don’t have a value, so somewhere along the line it’s either not getting added or getting removed.

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

The topic ‘Undefined index of name in flex modules’ is closed to new replies.