Support

Account

Home Forums ACF PRO acf add local field to flexible content Reply To: acf add local field to flexible content

  • 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,
    		      )
    		);
      
      }
    
    ?>