{"id":1914,"date":"2021-10-06T09:21:08","date_gmt":"2021-10-06T09:21:08","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/add-rule-condition-field-in-magento-2-admin-ui-component-form\/"},"modified":"2025-07-16T17:21:45","modified_gmt":"2025-07-16T11:51:45","slug":"add-rule-condition-field-in-magento-2-admin-ui-component-form","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/add-rule-condition-field-in-magento-2-admin-ui-component-form\/","title":{"rendered":"How to Add Rule Condition Field in Magento 2 Admin UI Component Form"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The default\u00a0Magento 2\u00a0offers the rule tree condition field using which the admin can configure the condition-based features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the admin may want to offer a discount coupon only on certain products or specific customer groups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As online stores grow complex, the condition-based features are used more. Additionally, if you are customizing your own features for a better shopping platform, you may need to&nbsp;<em><strong>add rule condition field in Magento 2 admin UI component form<\/strong><\/em>&nbsp;as shown below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/09\/rule-tree-condition-tree-field.png\" alt=\"rule-tree-condition-tree-field\" class=\"wp-image-16445\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You can do so with the below code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to&nbsp;Add Rule Condition Field in Magento 2 Admin UI Component Form:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<em><strong>[Vendor]\/[Module]\/view\/adminhtml\/layout\/route_controller_grid.xml<\/strong><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;fieldset name=\"conditions\">\n    &lt;argument name=\"data\" xsi:type=\"array\">\n        &lt;item name=\"config\" xsi:type=\"array\">\n            &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\">Conditions&lt;\/item>\n            &lt;item name=\"collapsible\" xsi:type=\"boolean\">true&lt;\/item>\n            &lt;item name=\"sortOrder\" xsi:type=\"number\">10&lt;\/item>\n        &lt;\/item>\n    &lt;\/argument>\n    &lt;container name=\"conditions\" >\n        &lt;argument name=\"data\" xsi:type=\"array\">\n            &lt;item name=\"config\" xsi:type=\"array\">\n                &lt;item name=\"sortOrder\" xsi:type=\"number\">10&lt;\/item>\n            &lt;\/item>\n        &lt;\/argument>\n        &lt;htmlContent name=\"html_content\">\n            &lt;argument name=\"block\" xsi:type=\"object\">Magento\\SalesRule\\Block\\Adminhtml\\Promo\\Quote\\Edit\\Tab\\Conditions&lt;\/argument>\n        &lt;\/htmlContent>\n    &lt;\/container>\n&lt;\/fieldset><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it. Also you can&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/validate-condition-rules-in-a-custom-module-in-magento-2\/\">Magento 2 custom attribute validation rule<\/a>&nbsp;using ruleFactory enhances e-commerce customization and efficiency, allowing dynamic promotions and improving the user experience.<br><strong>Also read:<\/strong>&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/validate-condition-rules-in-a-custom-module-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Validate Condition Rules in Custom Module in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019d be happy to help.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default\u00a0Magento 2\u00a0offers the rule tree condition field using which the admin can configure the condition-based features. For example, the admin may want to offer&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1914","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1914"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1914\/revisions"}],"predecessor-version":[{"id":18018,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1914\/revisions\/18018"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}