ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Feature Field Grouping (Issue 4123 Req 4)

Open ZacharyRener opened this issue 8 months ago • 1 comments

Description of the Change

Field grouping: We need a way to indicate that a group of fields belongs together. It could be just a common indentation or a real grouping indicator.

#4123 Request 4

How to test the Change

In a Feature's set_settings_schema function, add an entry with the type 'field_group'. Set the 'key', 'label', and 'fields' properties inside of it. Example for Autosuggest.php:

$this->settings_schema = [
	[
		'type'   => 'field_group',
		'key'    => 'fieldgroupa',
		'label'  => 'Field Group ABC',
		'fields' => [
			[
				'default' => '.ep-autosuggest',
				'help'    => __( 'Input additional selectors where you would like to include autosuggest, separated by a comma. Example: <code>.custom-selector, #custom-id, input[type="text"]</code>', 'elasticpress' ),
				'key'     => 'autosuggest_selector',
				'label'   => __( 'Additional selectors', 'elasticpress' ),
				'type'    => 'text',
			],
			[
				'default' => '0',
				'key'     => 'trigger_ga_event',
				'help'    => __( 'Enable to fire a gtag tracking event when an autosuggest result is clicked.', 'elasticpress' ),
				'label'   => __( 'Trigger Google Analytics events', 'elasticpress' ),
				'type'    => 'checkbox',
			],
		],
	],
];

Result:

Considerations

  • This is set to work with requires_fields from #4141
  • Applies to both the fields within a group, and the group itself. Both can have the requires_fields property set

Changelog Entry

Added - Ability to create groups of fields

Credits

Props @ZacharyRener

Checklist:

ZacharyRener avatar May 01 '25 05:05 ZacharyRener

@ZacharyRener can we use this on the highlighting fields inside Post Search?

felipeelia avatar May 28 '25 12:05 felipeelia