Support

Account

Home Forums ACF PRO acf add local field to flexible content

Solved

acf add local field to flexible content

  • I’m trying to add a local field to a local field group The local field is a repeated field. The local field group is flexible content.

    I’m getting no errors. I can’t see what I’m doing wrong.

    
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array (
        'key' => 'group_56ff5b11d1775',
        'title' => 'add component',
        'fields' => array (
            array (
                'key' => 'field_56ff5b1a77c75',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ),
                'button_label' => 'Add Row',
                'min' => '',
                'max' => '',
                'layouts' => array (
                    array (
                        'key' => 'subfields',
                        'name' => 'sample_label',
                        'label' => 'sample label',
                        'display' => 'block',
                        'sub_fields' => array (
    
                          //field to import here
    
                        ),
                        'min' => '',
                        'max' => '',
                    ),
                ),
            ),
        ),
        'location' => array (
            array (
                array (
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'post',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
        'active' => 1,
        'description' => '',
    ));
    
    endif;
    
    //import this repeater field into the above flexible content
    
    acf_add_local_field(array(
          array (
            'key' => 'field_to_import',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'subfields', //parent
            'sub_fields' => array (
                array (
                    'key' => 'field_5237950f6c6e4',
                    'label' => 'url',
                    'name' => 'img_link_url',
                    'type' => 'text',
                    'instructions' => 'leave blank if link is not required',
                    'formatting' => 'html',
                ),
            ),
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          ),
    ))
  • Looking at the settings of existing fields, a sub field of a flex field has the following settings

    
    // this argument is the post ID of the flex field
    $field['parent'] = $parent_post_id;
    // I don't know if this can be the flex field key or it must be the post ID.
    
    // this argument is the key of the layout
    $field['parent_layout'] = $parent_layout_key;
    

    I’m not at all sure that you can add a field to a layout, it’s not really listed in the documentation https://www.advancedcustomfields.com/resources/register-fields-via-php/, but if you can then you’ll probably need to include these settings.

    You can see what the settings of any field type are by creating some examples and creating some acf/load_field filters and in the filter display the field settings. This usually helps me figure out what I can change or what I need to add. https://www.advancedcustomfields.com/resources/acfload_field/

    
    add_filter('acf/load_field/name=my_field_name', 'my_acf_load_field');
    function my_acf_load_field($field) {
      echo '<pre>'; print_r($field); echo '</pre>';
      return $field;
    }
    
    
  • here is the full output of flexible content. i guess i just cant do what i wanted as i have tried specifying the parent as ‘subfields’ i also tried ‘field_subfields’ and neither worked. Its a real shame that we can import simple single fields into other simple field structures but cant do the same with flexible content.

    the reason i am trying to do this is I want to manage and reuse parts of flexible content arrays more effectively. Are there any other methods you would suggest?

    Array
    (
        [ID] => 0
        [key] => field_subfields
        [label] => flexible content
        [name] => flexible_content
        [prefix] => 
        [type] => flexible_content
        [value] => 
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => group_56ff5b11d1775
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => flexible_content
        [_input] => 
        [_valid] => 1
        [button_label] => Add Row
        [min] => 
        [max] => 
        [layouts] => Array
            (
                [0] => Array
                    (
                        [key] => subfields
                        [name] => sample_label
                        [label] => sample label
                        [display] => block
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_to_import
                                        [label] => Repeatable image with optional link
                                        [name] => repeatable_imgs
                                        [prefix] => 
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_subfields
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => repeatable_imgs
                                        [_input] => 
                                        [_valid] => 1
                                        [row_min] => 0
                                        [row_limit] => 
                                        [layout] => table
                                        [button_label] => Add image
                                        [parent_layout] => subfields
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 0
                                                        [key] => field_5237950f6c6e4
                                                        [label] => url
                                                        [name] => img_link_url
                                                        [prefix] => 
                                                        [type] => text
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => leave blank if link is not required
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => field_to_import
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => img_link_url
                                                        [_input] => 
                                                        [_valid] => 1
                                                        [formatting] => html
                                                        [default_value] => 
                                                        [maxlength] => 
                                                        [placeholder] => 
                                                        [prepend] => 
                                                        [append] => 
                                                        [readonly] => 0
                                                        [disabled] => 0
                                                    )
    
                                            )
    
                                        [min] => 0
                                        [max] => 0
                                    )
    
                            )
    
                        [min] => 
                        [max] => 
                    )
    
            )
    
    )
    
  • I asked Elliot and this was his response.

    The flexible content field uses the acf_get_fields() function to load all children fields.
    So, all you would need to do is make sure that the ‘sub field’ contains the correct ‘parent’ reference so that it is found by the flexible content field

    Also, the sub field needs an extra setting called ‘parent_layout’ containing the string layout key.

    Checkout the pro/fields/flexible-content.php load_field function

    So, it should be possible. I don’t have time to test it out right now. I’ll do some testing to see if I can figure it out as soon as I can unless you say you’ve figured it out.

  • Thanks for your help with this. I’m still in struggled town and still haven’t managed to get it to work. I’m a bit confused by this part “extra setting called ‘parent_layout’ containing the string layout key” in particular the string layout key

  • Sorry it took so long to get back to you. There were a few problems with your code, you have some extra nesting on arrays() is isn’t needed in places. Also I learned that if you’re adding fields using acf_add_local_field() that you need to add fields to a repeater, you can’t just add the repeater including the sub fields, what that means is that each individual field must be added separately.

    this code works

    
    
      if( function_exists('acf_add_local_field_group') ) {
      
        acf_add_local_field_group(
          array (
            'key' => 'group_56ff5b11d1775',
            'title' => 'add component',
            'fields' => array (
              array (
                'key' => 'field_56ff5b1a77c75',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
              'button_label' => 'Add Row',
              'min' => '',
              'max' => '',
              'layouts' => array (
                array (
                  'key' => '56ff5b1a77c76',
                  'name' => 'sample_label',
                  'label' => 'sample label',
                  'display' => 'block',
                  'min' => '',
                  'max' => '',
                ),
              ),
              ),
            ),
            'location' => array (
              array (
                array (
                  'param' => 'post_type',
                  'operator' => '==',
                  'value' => 'post',
                ),
              ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
          )
        );
        
        acf_add_local_field(
          array (
            'key' => 'field_56ff5b1a77c79',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'field_56ff5b1a77c75', //flex field key
            'parent_layout' => '56ff5b1a77c76', // layout key
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          )
        );
        
        acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_56ff5b1a77c79',
          )
        );
      
      }
    
  • awesome. that works. im now trying to solve it using tabs too. here im trying to break the fields into two tabs. havent figured it out yet though as the last tab has no fields attached to it.

    <?php if( function_exists('acf_add_local_field_group') ) {
      
        acf_add_local_field_group(
          array (
            'key' => 'group_56ff5b11d1775',
            'title' => 'add component',
            'fields' => array (
              array (
                'key' => 'field_56ff5b1a77c75',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
              'button_label' => 'Add Row',
              'min' => '',
              'max' => '',
              'layouts' => array (
                array (
                  'key' => '56ff5b1a77c76',
                  'name' => 'sample_label',
                  'label' => 'sample label',
                  'display' => 'block',
                  'min' => '',
                  'max' => '',
                ),
              ),
              ),
            ),
            'location' => array (
              array (
                array (
                  'param' => 'post_type',
                  'operator' => '==',
                  'value' => 'post',
                ),
              ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
          )
        );
        
        acf_add_local_field(
          array (
    	'key' => 'field_57032097d3ac0',
    	'label' => 'Content Columns',
    	'name' => 'content_columns',
    	'type' => 'tab',
            'parent' => 'field_56ff5b1a77c75', //flex field key
            'parent_layout' => '56ff5b1a77c76', // layout key
    	'instructions' => '',
    	'required' => 0,
    	'conditional_logic' => 0,
    	'wrapper' => array (
    		'width' => '',
    		'class' => '',
    		'id' => '',
    	),
    	'placement' => 'top',
    	'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
          array (
            'key' => 'field_56ff5b1a77c79',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'field_56ff5b1a77c75', //flex field key
            'parent_layout' => '56ff5b1a77c76', // layout key
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          )
        );
        
        acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_56ff5b1a77c79',
          )
        );
    
        acf_add_local_field(
          array (
    	      'key' => 'field_570320bbd3ac1',
    	      'label' => 'Row Styling',
    	      'name' => 'row_styling',
    	      'type' => 'tab',
    	      'parent' => 'field_56ff5b1a77c75', //flex field key
    	      'parent_layout' => '56ff5b1a77c76', // layout key
    	      'instructions' => '',
    	      'required' => 0,
    	      'conditional_logic' => 0,
    	      'wrapper' => array (
    		      'width' => '',
    		      'class' => '',
    		      'id' => '',
    	      ),
    	      'placement' => 'top',
    	      'endpoint' => 1,
          )
        );
    
        acf_add_local_field(
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'parent' => 'field_570320bbd3ac1', //flex field key
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		      )
    		);
      
      }
    
    ?>
    
  • You’re last field does not have the `parent_layout’ value.

  • that is not the issue. the row class needs to be outside of the repeater.

    here is what i am trying to replicate with tabs and ‘add local field group’

    <?php
    
    acf_add_local_field_group(array (
    	'key' => 'group_57031a424348c',
    	'title' => 'content_columns',
    	'fields' => array (
    		array (
    			'key' => 'field_57032097d3ac0',
    			'label' => 'Content Columns',
    			'name' => 'content_columns',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array (
    			'key' => 'field_57031a4b179b3',
    			'label' => 'content columns',
    			'name' => 'content_columns',
    			'type' => 'repeater',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'collapsed' => '',
    			'min' => '',
    			'max' => '',
    			'layout' => 'table',
    			'button_label' => 'Add Content Column',
    			'sub_fields' => array (
    				array (
    					  'key' => 'field_5704f37ef4e95',
    					  'label' => 'text_area',
    					  'name' => 'text_area',
    					  'type' => 'wysiwyg',
    					  'instructions' => '',
    					  'required' => 0,
    					  'conditional_logic' => 0,
    					  'wrapper' => array (
    						  'width' => '',
    						  'class' => '',
    						  'id' => '',
    					  ),
    					  'default_value' => '',
    					  'tabs' => 'all',
    					  'toolbar' => 'full',
    					  'media_upload' => 1,
    				),
    			),
    		),
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'Row Styling',
    			'name' => 'row_styling',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array (
    			'key' => 'field_57031acc179b6',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'post',
    			),
    		),
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'page',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    ?>
    
  • thanks for your help. this is working now. it was related to another issue

    <?php if( function_exists('acf_add_local_field_group') ) {
      
        acf_add_local_field_group(
          array (
            'key' => 'group_56ff5b11d1775',
            'title' => 'add component',
            'fields' => array (
              array (
                'key' => 'field_flex_key',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
              'button_label' => 'Add Row',
              'min' => '',
              'max' => '',
              'layouts' => array (
                array (
                  'key' => 'layout_key',
                  'name' => 'sample_label',
                  'label' => 'sample label',
                  'display' => 'block',
                  'min' => '',
                  'max' => '',
                ),
              ),
              ),
            ),
            'location' => array (
              array (
                array (
                  'param' => 'post_type',
                  'operator' => '==',
                  'value' => 'post',
                ),
              ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
          )
        );
        
        acf_add_local_field(
          array (
    	'key' => 'field_57032097d3ac0',
    	'label' => 'Content Columns',
    	'name' => 'content_columns',
    	'type' => 'tab',
            'parent' => 'field_flex_key', //flex field key
            'parent_layout' => 'layout_key', // layout key
    	'instructions' => '',
    	'required' => 0,
    	'conditional_logic' => 0,
    	'wrapper' => array (
    		'width' => '',
    		'class' => '',
    		'id' => '',
    	),
    	'placement' => 'top',
    	'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
          array (
            'key' => 'field_repeatable_key',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'field_flex_key', //flex field key
            'parent_layout' => 'layout_key', // layout key
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          )
        );
        
        acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_repeatable_key',
          )
        );
    
        acf_add_local_field(
          array (
    	      'key' => 'field_styling_tab',
    	      'label' => 'Row Styling',
    	      'name' => 'row_styling',
    	      'type' => 'tab',
    	      'parent' => 'field_flex_key', //flex field key
    	      'parent_layout' => 'layout_key', // layout key
    	      'instructions' => '',
    	      'required' => 0,
    	      'conditional_logic' => 0,
    	      'wrapper' => array (
    		      'width' => '',
    		      'class' => '',
    		      'id' => '',
    	      ),
    	      'placement' => 'top',
    	      'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'parent' => 'field_flex_key', //flex field key
    			'parent_layout' => 'layout_key', // layout key
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		      )
    		);
      
      }
    
    ?>
  • i realize the values are not outputting on the frontend. how would i output the value of

    acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_repeatable_key',
          )
        );

    (keep in mind this is a field within a repeater) on the frontend

  • You’ve got several nested repeaters and you’ll need to use several loop and get_sub_field() or the_sub_field(). This document covers most of it. https://www.advancedcustomfields.com/resources/have_rows/

  • sweet, however the issue is actually the_flexible_field(),
    get_row_layout() is not finding the layout. i have tried getting ‘repeat_content’ and ‘content_columns’ but neither is working

    <?php
    
        while(the_flexible_field('flexible_content')): 
          echo '<h2>flexi heading</h2>';
          switch (get_row_layout()):
    	 
    	  case 'repeat_content':
    	    echo '<h2>heading</h2>';
    		  if (function_exists('repeat_content')):
    		       content_columns();
    		    else:
    		      echo 'content col is not enabled';
    		  endif;
    	  break;
    	  case 'includes':
    		  if (function_exists('ml_acf_include')): 
    		      ml_acf_include();
    		    else:
    		      echo 'includes is not enabled';
    		    endif;
    	  break;
    	endswitch;
        endwhile; 
    

    heres the output of flexible_content

    Array
    (
        [ID] => 0
        [key] => field_flex_key
        [label] => flexible content
        [name] => flexible_content
        [prefix] => 
        [type] => flexible_content
        [value] => 
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => group_56ff5b11d1775
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => flexible_content
        [_input] => 
        [_valid] => 1
        [button_label] => Add Component
        [min] => 
        [max] => 
        [layouts] => Array
            (
                [0] => Array
                    (
                        [key] => layout_key
                        [name] => layouts
                        [label] => Components
                        [display] => block
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57032097d3ac0
                                        [label] => Content Columns
                                        [name] => content_columns
                                        [prefix] => 
                                        [type] => tab
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => content_columns
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [placement] => top
                                        [endpoint] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_repeatable_key
                                        [label] => Repeatable image with optional link
                                        [name] => repeat_content
                                        [prefix] => 
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => repeat_content
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [row_min] => 0
                                        [row_limit] => 
                                        [layout] => table
                                        [button_label] => Add Component
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 0
                                                        [key] => field_56a749bdc0553
                                                        [label] => Content Column
                                                        [name] => text_area
                                                        [prefix] => 
                                                        [type] => wysiwyg
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => field_repeatable_key
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => text_area
                                                        [_input] => 
                                                        [_valid] => 1
                                                        [default_value] => 
                                                        [tabs] => all
                                                        [toolbar] => full
                                                        [media_upload] => 1
                                                    )
    
                                            )
    
                                        [min] => 0
                                        [max] => 0
                                        [collapsed] => 
                                    )
    
                                [2] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_styling_tab
                                        [label] => Row Styling
                                        [name] => row_styling
                                        [prefix] => 
                                        [type] => tab
                                        [value] => 
                                        [menu_order] => 2
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => row_styling
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [placement] => top
                                        [endpoint] => 0
                                    )
    
                                [3] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_570320bbd3ac1
                                        [label] => row class
                                        [name] => row_class
                                        [prefix] => 
                                        [type] => text
                                        [value] => 
                                        [menu_order] => 3
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => row_class
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [default_value] => 
                                        [placeholder] => 
                                        [prepend] => 
                                        [append] => 
                                        [maxlength] => 
                                        [readonly] => 0
                                        [disabled] => 0
                                    )
    
                                [4] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031ca0179ba
                                        [label] => boxed content
                                        [name] => boxed_content
                                        [prefix] => 
                                        [type] => true_false
                                        [value] => 
                                        [menu_order] => 4
                                        [instructions] => the width of the content will be limited to the amount set in the stylesheet code.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => boxed_content
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [message] => 
                                        [default_value] => 1
                                    )
    
                                [5] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031c64179b9
                                        [label] => invert colors
                                        [name] => invert_colors
                                        [prefix] => 
                                        [type] => true_false
                                        [value] => 
                                        [menu_order] => 5
                                        [instructions] => dark color scheme for this panel instead of a light color scheme
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => invert_colors
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [message] => invert color scheme
                                        [default_value] => 0
                                    )
    
                                [6] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031b1b179b8
                                        [label] => style options
                                        [name] => style_options
                                        [prefix] => 
                                        [type] => select
                                        [value] => 
                                        [menu_order] => 6
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => style_options
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [choices] => Array
                                            (
                                                [None] => None
                                                [option 1] => option 1
                                                [option 2] => option 2
                                            )
    
                                        [default_value] => Array
                                            (
                                            )
    
                                        [allow_null] => 0
                                        [multiple] => 0
                                        [ui] => 0
                                        [ajax] => 0
                                        [placeholder] => 
                                        [disabled] => 0
                                        [readonly] => 0
                                    )
    
                                [7] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031afc179b7
                                        [label] => bg_image
                                        [name] => bg_image
                                        [prefix] => 
                                        [type] => image
                                        [value] => 
                                        [menu_order] => 7
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => bg_image
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [return_format] => array
                                        [preview_size] => thumbnail
                                        [library] => all
                                        [min_width] => 
                                        [min_height] => 
                                        [min_size] => 
                                        [max_width] => 
                                        [max_height] => 
                                        [max_size] => 
                                        [mime_types] => 
                                    )
    
                            )
    
                        [min] => 
                        [max] => 
                    )
    
            )
    
    )
  • I really wouldn’t be able to say why it’s not working, I don’t know what those other functions are.

    I would start with creating a similar group in ACF and exporting it to PHP and then making sure I have my local field group set up properly, all the right values and required keys and such. Generally when I’m putting field groups into php that what I do anyway. I build the field group that I want and make sure it’s working properly and then I export it. At that point I pull it apart to do anything dynamic that needs to be done with including or not including certain fields and make any other adjustments.

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

The topic ‘acf add local field to flexible content’ is closed to new replies.