Magento – Ui-component form (Adding drop down field)in magento 2

dependencydrop-downsmagento2.2.2ui-formuicomponent

I need to create backend admin form which contains two dropdown fields.But One is dependent on other. One dropdown contains attributes like brand,color etc.. The second one contains associate options of the attribute what you select in the first dropdown. If you select Brand, It should show all the available brands in second dropdown.

enter image description here

If you select color It would show all the available colors in the second dropdown
enter image description here

Is above scenario is possible in ui-component form in magento 2. Please suggest me, Am I need to create ui-component form or php form to do my task. Thanks in advance

Best Answer

Please check example

https://github.com/Ximbo/magento2-dependent-fields

This example uses attributes color and manufaturer (as defined in di.xml). Also it does not cover dataProvider usage and other things related to the ui component. Just about dependent selects.