acf_field_repeater::render_field_settings()publicACF 3.6

Create extra options for your field. This is rendered when editing a field. The value of $field['name'] can be used (like bellow) to save extra data to the $field

@type action

{} Это метод класса: acf_field_repeater{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$acf_field_repeater = new acf_field_repeater();
$acf_field_repeater->render_field_settings( $field );
$field (обязательный)
-

Список изменений

С версии 3.6 Введена.

Код acf_field_repeater::render_field_settings() ACF 5.10.2

<?php
function render_field_settings( $field ) {

	// vars
	$args = array(
		'fields' => $field['sub_fields'],
		'parent' => $field['ID'],
	);

	?>
<tr class="acf-field acf-field-setting-sub_fields" data-setting="repeater" data-name="sub_fields">
	<td class="acf-label">
		<label><?php _e( 'Sub Fields', 'acf' ); ?></label>
		<p class="description"></p>		
	</td>
	<td class="acf-input">
		<?php

		acf_get_view( 'field-group-fields', $args );

		?>
	</td>
</tr>
	<?php

	// rows
	$field['min'] = empty( $field['min'] ) ? '' : $field['min'];
	$field['max'] = empty( $field['max'] ) ? '' : $field['max'];

	// collapsed
	$choices = array();
	if ( $field['collapsed'] ) {

		// load sub field
		$sub_field = acf_get_field( $field['collapsed'] );

		// append choice
		if ( $sub_field ) {
			$choices[ $sub_field['key'] ] = $sub_field['label'];
		}
	}

	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Collapsed', 'acf' ),
			'instructions' => __( 'Select a sub field to show when row is collapsed', 'acf' ),
			'type'         => 'select',
			'name'         => 'collapsed',
			'allow_null'   => 1,
			'choices'      => $choices,
		)
	);

	// min
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Minimum Rows', 'acf' ),
			'instructions' => '',
			'type'         => 'number',
			'name'         => 'min',
			'placeholder'  => '0',
		)
	);

	// max
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Maximum Rows', 'acf' ),
			'instructions' => '',
			'type'         => 'number',
			'name'         => 'max',
			'placeholder'  => '0',
		)
	);

	// layout
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Layout', 'acf' ),
			'instructions' => '',
			'class'        => 'acf-repeater-layout',
			'type'         => 'radio',
			'name'         => 'layout',
			'layout'       => 'horizontal',
			'choices'      => array(
				'table' => __( 'Table', 'acf' ),
				'block' => __( 'Block', 'acf' ),
				'row'   => __( 'Row', 'acf' ),
			),
		)
	);

	// button_label
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Button Label', 'acf' ),
			'instructions' => '',
			'type'         => 'text',
			'name'         => 'button_label',
			'placeholder'  => __( 'Add Row', 'acf' ),
		)
	);

}