How to Manage Checkbox field in ui component form Magento 2?

You can Manage/add the checkbox component field in admin panel Ui Component form Magento. You can add Checkbox type field with toggle, radio and regular checkbox option.

Use formElement as checkbox in XML file with field tag. <field name=”my_field” sortOrder=”10″ formElement=”checkbox”>

Add below XML code snippet for the checkbox component in custom form xml file to show toggle,

If you want to show checkbox as toggle, use node,
<prefer>toggle</prefer>

You can display checkbox as radio option using,
<prefer>radio</prefer> in <formElements><settings /> node.

If you want to display a regular checkbox field, you don’t need to write <prefer> node in <formElements><settings />.
The default value is the regular checkbox icon for the checkbox field.

Leave a Reply