<?php
/**
 * Name of the acf field
 * https://www.advancedcustomfields.com/resources/register-fields-via-php/
 * https://awhitepixel.com/advanced-custom-fields-complete-reference-adding-fields-groups-by-code/
 * https://gist.github.com/mgburns/23ffdbd20c580c715c47
 *
 * Keys are in random hash (use https://marketplace.visualstudio.com/items?itemName=Oliver.hash-generator)
 *
 * @category ACF fields
 * @author Krik
 */

// Register ACF fields
if (function_exists('acf_add_local_field_group')) {
	add_action('acf/init', 'register_acf_fields');
}

function register_acf_fields ()
{
	acf_add_local_field_group([
		'key' => 'field_',
		'title' => 'Field group',
		'label_placement' => 'top',
		'menu_order' => 0,
		'style' => 'default',
		'position' => 'normal',
		'location' => array (
			array (
				array (
					'param' => 'block',
					'operator' => '==',
					'value' => 'acf/example',
				),
			),
		),
		'fields' => array (
			array (
				'key' => 'field_',
				'label' => 'First Field',
				'name' => 'first_field',
				'type' => 'text',
			),
			array(
				'key' => 'field_',
				'label' => 'Second Field',
				'name' => 'second_field',
				'type' => 'textarea',
				'required' => 1,
			),
			array(
				'key' => 'field_',
				'label' => 'Repeater fields',
				'name' => 'repeater_fields',
				'type' => 'repeater',
				'required' => 0,
				'min' => 0,
				'max' => 0,
				'layout' => 'table',
				'button_label' => '',
				'sub_fields' => array(
					array(
						'key' => 'field_',
						'label' => 'Repeater Text Field',
						'name' => 'repeater_text_field',
						'type' => 'text',
					),
				),
			),
		),
	]);
}
