Details
-
Improvement
-
Resolution: Workaround exists
-
Neutral
-
None
-
6.2.10
-
None
-
None
Description
It would be useful to have a select all by default option for checkBoxGroupField
The following custom factory class is an example that will create the field with all checked by default.
public class CustomCheckBoxGroupFieldFactory<T> extends CheckBoxGroupFieldFactory<T>{ public CustomCheckBoxGroupFieldFactory(CheckBoxGroupFieldDefinition<T> definition, ComponentProvider componentProvider, SelectFieldSupport<Set<T>> selectFieldSupport) { super(definition, componentProvider, selectFieldSupport); } @Override public CheckBoxGroup<T> createField() { CheckBoxGroup<T> group = (CheckBoxGroup<T>) super.createField(); Stream<T> stream = group.getDataProvider().fetch(new Query()); Set<T> set = stream.collect(Collectors.toSet()); group.updateSelection(set, group.getEmptyValue()); return group; } }
To implement it, this logic should be added to info.magnolia.ui.field.factory.CheckBoxGroupFieldFactory as well as a new property in the definition class that let users enable/disable this behaviour (a boolean allCheckedByDefault)
Checklists
Acceptance criteria