I have created toggle button by uicomponent in one group and some other fields by dataprovider way in another group.

Can I get toggle button into group created by dataprovider way. As it is not possible toggle checkbox to be created without uicomponent.

enter image description here

1 Answer 1


Toggle checkbox can be created via DataProvider as well. DataProvider (PHP) and UI Component (XML) files are two ways to generate the same configuration to render the elements.

Therefore you can create any kind of elements in both ways. Just need to make sure your code use the correct format and don't miss the required config.

In your case, you can try to move the config for toggle checkbox from XML file to your meta array in your DataProvider with the same key/values.

  • Hi @Daniel, I have searched a lot and find out toggle option can be created only by uicomponent but If you could give an example of how to add toggle checkbox by creating php function and adding it as a child in modifyMeta() I will accept your answer.
    – Ajwad Syed
    Commented May 1, 2019 at 9:33
  • Hi @Ajwad, You can refer to the product form, looking at the status attribute. Class: \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General Function: customizeStatusField It's an example of the toggle checkbox. Commented May 1, 2019 at 9:57
  • Yes, what is the argument here $meta = $this->customizeStatusField($meta) ?
    – Ajwad Syed
    Commented May 1, 2019 at 10:08
  • @Ạjwad It's just an array store your meta information. If you are using the modifier, your modifyMeta function should have an $meta as an argument already. Commented May 1, 2019 at 10:12
  • what is the meaning of this error..getting it after properly adding that toggle function into my dataprovider: Exception #0 (Magento\Framework\Exception\LocalizedException): The "componentType" configuration parameter is required for the "toggle" component.
    – Ajwad Syed
    Commented May 1, 2019 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.