ElasticPress
ElasticPress copied to clipboard
Feature Field Grouping (Issue 4123 Req 4)
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:
- [x] I agree to follow this project's Code of Conduct.
- [x] I have updated the documentation accordingly.
- [x] I have added Critical Flows, Test Cases, and/or End-to-End Tests to cover my change.
- [x] All new and existing tests pass.
@ZacharyRener can we use this on the highlighting fields inside Post Search?