What exactly is the checkboxGroupField used for?
And why not just using the checkboxSelectField?

I am building a library that's gonna be required by a couple of my future Craft plugins and Craft modules. That library is dealing with several field types in the Craft CP.
So, basically it provides some features for programmatically adding fields of some of the basic (Craft built-in) field types (such as textField, colorField, lightswitchField and so on).

Now, what is confusing for me is, that there are two Twig macros in ./vendor/craftcms/cms/src/templates/_includes/forms.html for a bunch of checkboxes: checkboxGroupField and checkboxSelectField.
Is there any reason my library should provide a checkboxGroupField over a checkboxSelectField? The latter one even provides an "all" option (showAllOption).

When comparing both template files ./vendor/craftcms/cms/src/templates/_includes/forms/checkboxSelect.html and ./vendor/craftcms/cms/src/templates/_includes/forms/checkboxGroup.html I don't really see what the differences are (apart from said "all" option).
Thus, I don't see any important reason I should not forget about the checkboxGroupField. But still, I am quite unsure about why the checkboxGroupField exists, what it should be used for and if I should consider it at all.

So, what do you think? Should I just ignore the checkboxGroupField? Under what circumstances is it more useful than the checkboxSelectField? As far as I can see the "checkbox group field" doesn't have any actual benefit since the "all" option of the "checkbox select field" is optional and can be omitted. Do I miss anything obvious here?

Side question:
What about that input field of type="hidden" which is being rendered in the checkboxGroupField template ? What's that for?

… I think I don't get the actual meaning of the whole checkboxGroupField thing (while checkboxSelectField is pretty clear to me).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.