Repeater

This field type renders repeatable field groups.

Parameters

  • fields - an array of field parameters for a group.

Example

The code below renders a group with the text and number fields. The text field requires at least 10 characters to be entered, while the minimum required value for the number field is 100. The field group can be repeated using the Add Item button.

echo ( new HivePress\Fields\Repeater(
	[
		'name'   => 'custom_field',

		'fields' => [
			'custom_text'   => [
				'placeholder' => 'Custom text',
				'type'        => 'text',
				'min_length'  => 10,
				'_order'      => 123,
			],

			'custom_number' => [
				'placeholder' => 'Custom number',
				'type'        => 'number',
				'min_value'   => 100,
				'_order'      => 321,
			],
		],
	]
) )->render();

Last updated