Support

Account

Home Forums General Issues Register fields via PHP > Repeater Reply To: Register fields via PHP > Repeater

  • You could create a Repeater Field in Backend use the Export Tool to see how you can do it. A Repeater with a textfield looks like this.

    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array(
    	'key' => 'group_5c18f89ca825f',
    	'title' => 'repeater',
    	'fields' => array(
    		array(
    			'key' => 'field_5c18f8a29941c',
    			'label' => 'repeaterField',
    			'name' => 'repeaterFieldName',
    			'type' => 'repeater',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'collapsed' => '',
    			'min' => 0,
    			'max' => 0,
    			'layout' => 'table',
    			'button_label' => '',
    			'sub_fields' => array(
    				array(
    					'key' => 'field_5c18f8ba9941d',
    					'label' => 'repeaterField-TextField',
    					'name' => 'repeaterfield-textfieldName',
    					'type' => 'text',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => 0,
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'default_value' => '',
    					'placeholder' => '',
    					'prepend' => '',
    					'append' => '',
    					'maxlength' => '',
    				),
    			),
    		),
    	),
    	'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;