{"id":419178,"date":"2024-01-25T06:35:34","date_gmt":"2024-01-25T06:35:34","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=419178"},"modified":"2024-07-10T06:07:22","modified_gmt":"2024-07-10T06:07:22","slug":"add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/","title":{"rendered":"Add UI-Select with search filter using the block method on the Admin form in Magento 2"},"content":{"rendered":"\n<p>Here we learn how to add or create a UI-Select field using the block method on the Admin form.<\/p>\n\n\n\n<p>Let\u2019s start step by step.<br>You must have installed <a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2 custom Module<\/a> on which you are going to implement this.<\/p>\n\n\n\n<p><strong>Step 1: <\/strong>We need to create the layout file to define the  admin form in <strong>view\/adminhtml\/layout\/webkulblog_account_edit.xml<\/strong> :<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;!--\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n-->\n&lt;page xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" layout=\"admin-2columns-left\" xsi:noNamespaceSchemaLocation=\"urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd\">\n    &lt;update handle=\"styles\"\/>\n    &lt;update handle=\"editor\"\/>\n    &lt;body>\n        &lt;referenceBlock name=\"menu\">\n            &lt;action method=\"setActive\">\n               &lt;argument name=\"itemId\" xsi:type=\"string\">\n                        Webkul_Custom:webkulblog\n                    &lt;\/argument>\n        &lt;\/action>\n        &lt;\/referenceBlock>\n        &lt;referenceBlock name=\"page.title\">\n            &lt;action method=\"setTitleClass\">\n            &lt;argument name=\"class\" xsi:type=\"string\">\n                        complex\n                    &lt;\/argument>\n        &lt;\/action>\n        &lt;\/referenceBlock>\n    &lt;\/body>\n&lt;\/page><\/pre>\n<\/div><\/div>\n\n\n\n<p><strong>Step 2:<\/strong> Create the block file,&nbsp;<strong><code>Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit<\/code>.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\nnamespace Webkul\\Custom\\Block\\Adminhtml\\Account;\n\nclass Edit extends \\Magento\\Backend\\Block\\Widget\\Form\\Container\n{\n    \/**\n     * Initialize\n     *\n     * @return void\n     *\/\n    protected function _construct()\n    {\n        $this-&gt;_objectId = &#039;entity_id&#039;;\n        $this-&gt;_blockGroup = &#039;Webkul_Custom&#039;;\n        $this-&gt;_controller = &#039;adminhtml_account&#039;;\n        parent::_construct();\n        if ($this-&gt;_isAllowedAction(&#039;Webkul_Custom::accountedit&#039;)) {\n            $this-&gt;buttonList-&gt;update(&#039;save&#039;, &#039;label&#039;, __(&#039;Save Account&#039;));\n        } else {\n            $this-&gt;buttonList-&gt;remove(&#039;save&#039;);\n        }\n        $this-&gt;buttonList-&gt;remove(&#039;delete&#039;);\n        $this-&gt;buttonList-&gt;remove(&#039;reset&#039;);\n    }\n\n    \/**\n     * Retrieve text for header element depending on loaded Group\n     *\n     * @return \\Magento\\Framework\\Phrase\n     *\/\n    public function getHeaderText()\n    {\n            return __(&#039;New Blog Account&#039;);\n    }\n\n    \/**\n     * Check permission for passed action\n     *\n     * @param string $resourceId\n     * @return bool\n     *\/\n    protected function _isAllowedAction($resourceId)\n    {\n        return $this-&gt;_authorization-&gt;isAllowed($resourceId);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 3:<\/strong> Create the block file,&nbsp;<strong><code>Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit<\/code>\\Tabs.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit;\n\nclass Tabs extends \\Magento\\Backend\\Block\\Widget\\Tabs\n{\n    \/**\n     * @param \\Magento\\Backend\\Block\\Template\\Context $context\n     * @param \\Magento\\Framework\\Json\\EncoderInterface $jsonEncoder\n     * @param \\Magento\\Backend\\Model\\Auth\\Session $authSession\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\Block\\Template\\Context $context,\n        \\Magento\\Framework\\Json\\EncoderInterface $jsonEncoder,\n        \\Magento\\Backend\\Model\\Auth\\Session $authSession,\n        array $data = &#091;]\n    ) {\n        parent::__construct($context, $jsonEncoder, $authSession, $data);\n    }\n\n    \/**\n     * Construct\n     *\n     * @return void\n     *\/\n    protected function _construct()\n    {\n        parent::_construct();\n        $this-&gt;setId(&#039;blog_account_tab&#039;);\n        $this-&gt;setDestElementId(&#039;edit_form&#039;);\n        $this-&gt;setTitle(__(&#039;Blog Account Information&#039;));\n    }\n\n    \/**\n     * Prepare Layout\n     *\n     * @return $this\n     *\/\n    protected function _prepareLayout()\n    {\n        $block = \\Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit\\Tab\\BlogAccount::class;\n        $this-&gt;addTab(\n            &#039;blog_account_info&#039;,\n            &#091;\n                &#039;label&#039; =&gt; __(&#039;Blog Account&#039;),\n                &#039;content&#039; =&gt; $this-&gt;getLayout()-&gt;createBlock($block, &#039;blog_account_info&#039;)-&gt;toHtml()\n            ]\n        );\n        return parent::_prepareLayout();\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 4:<\/strong> Create the block file,&nbsp;<strong><code>Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit<\/code>\\Tab\\BlogAccount.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit\\Tab;\n\nuse Magento\\Backend\\Block\\Widget\\Form\\Generic;\nuse Magento\\Backend\\Block\\Widget\\Tab\\TabInterface;\nuse Webkul\\Custom\\Block\\Adminhtml\\Widget\\Form\\Element\\FilterSelect;\n\nclass BlogAccount extends Generic implements TabInterface\n{\n\n    \/**\n     * @param \\Magento\\Backend\\Block\\Template\\Context $context\n     * @param \\Magento\\Framework\\Registry $registry\n     * @param \\Magento\\Framework\\Data\\FormFactory $formFactory\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\Block\\Template\\Context $context,\n        \\Magento\\Framework\\Registry $registry,\n        \\Magento\\Framework\\Data\\FormFactory $formFactory,\n        array $data = &#091;]\n    ) {\n        parent::__construct($context, $registry, $formFactory, $data);\n    }\n\n    \/**\n     * Prepare form\n     *\n     * @return $this\n     *\/\n    protected function _prepareForm()\n    {\n        $model = $this-&gt;_coreRegistry-&gt;registry(&#039;business_list_model&#039;);\n        $form = $this-&gt;_formFactory-&gt;create();\n        $fieldset = $form-&gt;addFieldset(\n            &#039;base_fieldset&#039;,\n            &#091;&#039;legend&#039; =&gt; __(&#039;Blog Account&#039;), &#039;class&#039; =&gt; &#039;fieldset-wide&#039;]\n        );\n\n        $fieldset-&gt;addType(&#039;filterselect&#039;, FilterSelect::class);\n        if ($model-&gt;getId()) {\n            $fieldset-&gt;addField(&#039;entity_id&#039;, &#039;hidden&#039;, &#091;&#039;name&#039; =&gt; &#039;entity_id&#039;]);\n        }\n\n        $fieldset-&gt;addField(\n            &#039;user_name&#039;,\n            &#039;text&#039;,\n            &#091;\n                &#039;name&#039; =&gt; &#039;user_name&#039;,\n                &#039;label&#039; =&gt; __(&#039;User Name&#039;),\n                &#039;title&#039; =&gt; __(&#039;User Name&#039;),\n                &#039;required&#039; =&gt; true,\n                &#039;note&#039; =&gt; __(&#039;Set the unique name for account.&#039;)\n            ]\n        );\n        $fieldset-&gt;addField(\n            &#039;access_data&#039;,\n            &#039;filterselect&#039;, \/\/custom type\n            &#091;\n                &#039;name&#039; =&gt; &#039;access_data&#039;,\n                &#039;label&#039; =&gt; __(&#039;Access data&#039;),\n                &#039;options&#039; =&gt; $this-&gt;getOptions(),\n                &#039;multiple&#039; =&gt; true,\n                &#039;required&#039; =&gt; true,\n            ]\n        );\n\n        if (!empty($model-&gt;getData())) {\n            $data = $model-&gt;getData();\n            if (isset($data&#091;&#039;access_data&#039;])) {\n                $data&#091;&#039;access_data&#039;] = explode(&#039;,&#039;, $data&#091;&#039;access_data&#039;] ?? &#039;&#039;);\n            }\n            $form-&gt;setValues($data);\n        }\n        $this-&gt;setForm($form);\n        return parent::_prepareForm();\n    }\n\n    \/**\n     * Get options\n     *\n     * @return array\n     *\/\n    public function getOptions()\n    {\n        return &#091;\n            &#091;&quot;value&quot; =&gt; &quot;1&quot;, &quot;label&quot; =&gt; &quot;Customer&quot;],\n            &#091;&quot;value&quot; =&gt; &quot;2&quot;, &quot;label&quot; =&gt; &quot;Admin&quot;],\n            &#091;&quot;value&quot; =&gt; &quot;3&quot;, &quot;label&quot; =&gt; &quot;Seller&quot;],\n            &#091;&quot;value&quot; =&gt; &quot;4&quot;, &quot;label&quot; =&gt; &quot;Guest&quot;],\n        ];\n    }\n\n    \/**\n     * Prepare label for tab\n     *\n     * @return \\Magento\\Framework\\Phrase\n     *\/\n    public function getTabLabel()\n    {\n        return __(&#039;Blog Account&#039;);\n    }\n\n    \/**\n     * Prepare title for tab\n     *\n     * @return \\Magento\\Framework\\Phrase\n     *\/\n    public function getTabTitle()\n    {\n        return __(&#039;Blog Account&#039;);\n    }\n\n    \/**\n     * CanShowTab\n     *\n     * @return bool\n     *\/\n    public function canShowTab()\n    {\n        return true;\n    }\n\n    \/**\n     * IsHidden\n     *\n     * @param bool\n     *\/\n    public function isHidden()\n    {\n        return false;\n    }\n\n    \/**\n     * Check permission for passed action\n     *\n     * @param string $resourceId\n     * @return bool\n     *\/\n    protected function _isAllowedAction($resourceId)\n    {\n        return $this-&gt;_authorization-&gt;isAllowed($resourceId);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step-5:<\/strong>  Add the custom type in block form using <strong>$fieldset-&gt;addType(&#8216;filterselect&#8217;, FilterSelect::class);<\/strong>, This custom type&#8217;s &#8220;<strong>filterselect<\/strong>&#8221; field data handling and rendering by block file :  <strong>Webkul\\Custom\\Block\\Adminhtml\\Widget\\Form\\Element\\FilterSelect.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Block\\Adminhtml\\Widget\\Form\\Element;\n\nuse Magento\\Framework\\Data\\Form\\Element\\AbstractElement;\nuse Magento\\Framework\\Data\\Form\\Element\\Factory as ElementFactory;\nuse Magento\\Framework\\Data\\Form\\Element\\CollectionFactory;\nuse Magento\\Framework\\Escaper;\nuse Magento\\Framework\\Serialize\\SerializerInterface;\n\n\/**\n * Class FilterSelect.\n *\/\nclass FilterSelect extends AbstractElement\n{\n    \/**\n     * @var \\Magento\\Framework\\View\\LayoutInterface\n     *\/\n    protected $layout;\n\n    \/**\n     * @var SerializerInterface\n     *\/\n    protected $serializer;\n\n    \/**\n     * Constructor.\n     *\n     * @param ElementFactory    $elementFactory\n     * @param CollectionFactory $collectionFactory\n     * @param Escaper           $escaper\n     * @param \\Magento\\Framework\\View\\LayoutInterface $layout\n     * @param SerializerInterface $serializer\n     * @param array             $data\n     *\/\n    public function __construct(\n        ElementFactory $elementFactory,\n        CollectionFactory $collectionFactory,\n        Escaper $escaper,\n        \\Magento\\Framework\\View\\LayoutInterface $layout,\n        SerializerInterface $serializer,\n        array $data = &#091;]\n    ) {\n        parent::__construct($elementFactory, $collectionFactory, $escaper, $data);\n        $this-&gt;layout = $layout;\n        $this-&gt;serializer = $serializer;\n        $this-&gt;setType(&#039;filterselect&#039;);\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function getElementHtml()\n    {\n        $html = $this-&gt;layout-&gt;createBlock(\\Magento\\Framework\\View\\Element\\Template::class)\n        -&gt;setTemplate(&#039;Webkul_Custom::business\/filterselect.phtml&#039;)\n        -&gt;setTemplateConfiguration($this-&gt;getCustomConfiguration())\n        -&gt;toHtml();\n        $html .= $this-&gt;getAfterElementHtml();\n        return $html;\n    }\n\n    \/**\n     * Get custom configuration\n     *\n     * @return string\n     *\/\n    public function getCustomConfiguration()\n    {\n        $data = $this-&gt;getData();\n        $defultConfiguration = $this-&gt;getDefaultConfiguration();\n        foreach($defultConfiguration as $key =&gt; $configuration){\n            if(isset($data&#091;$key])) {\n                $defultConfiguration&#091;$key] = $data&#091;$key];\n            }\n        }\n        return $this-&gt;serializer-&gt;serialize($defultConfiguration);\n    }\n\n    \/**\n     * Get defaults configuration\n     *\n     * @return array\n     *\/\n    public function getDefaultConfiguration()\n    {\n        $data = $this-&gt;getData();\n        $configurationData =&#091;\n            &quot;options&quot; =&gt; &#091;],\n            &quot;listVisible&quot; =&gt; false,\n            &quot;value&quot; =&gt; &#091;],\n            &#039;filterOptions&#039; =&gt; true,\n            &quot;chipsEnabled&quot; =&gt; true,\n            &quot;multiple&quot; =&gt; true,\n            &quot;showFilteredQuantity&quot; =&gt; true,\n            &quot;showCheckbox&quot; =&gt; false,\n            &quot;filterRateLimit&quot; =&gt; 500,\n            &quot;closeBtn&quot; =&gt; true,\n            &quot;closeBtnLabel&quot; =&gt; __(&#039;Done&#039;),\n            &quot;quantityPlaceholder&quot; =&gt; __(&#039;options&#039;),\n            &quot;hoverClass&quot; =&gt; &#039;_hover&#039;,\n            &quot;selectedPlaceholders&quot; =&gt; &#091;\n                &quot;defaultPlaceholder&quot; =&gt; __(&#039;Select...&#039;),\n                &quot;lotPlaceholders&quot; =&gt; __(&#039;Selected&#039;)\n            ],\n            &quot;component&quot; =&gt; &quot;Magento_Ui\/js\/form\/element\/ui-select&quot;,\n            &quot;template&quot; =&gt; &quot;Webkul_Custom\/filterselect&quot;, \/\/ custom template file\n            &quot;elementData&quot; =&gt; &#091;\n                &quot;name&quot; =&gt;  $this-&gt;getName(),\n                &quot;id&quot; =&gt; $this-&gt;getHtmlId(),\n            ],\n            &quot;required_entry&quot; =&gt; isset($data&#091;&#039;required&#039;]) ? $data&#091;&#039;required&#039;] : false\n       ];\n        return  $configurationData;\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 6:<\/strong> Create a phtml template file which is mentioned in getElementHtml() method of <strong>Step 5<\/strong>,<strong> view\/adminhtml\/templates\/business<\/strong>\/<strong>filterselect.phtml<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n?&gt;\n                &lt;div data-bind=&quot;scope: &#039;customFilterSelect&#039;&quot;&gt;\n                    &lt;!-- ko template: getTemplate() --&gt;&lt;!-- \/ko --&gt;\n                &lt;\/div&gt;\n                &lt;script type=&quot;text\/x-magento-init&quot;&gt;\n                    {\n                            &quot;*&quot;: {\n                                &quot;Magento_Ui\/js\/core\/app&quot;: {\n                                    &quot;components&quot;: {\n                                        &quot;customFilterSelect&quot;: &lt;?= \/* @noEscape *\/ $block-&gt;getTemplateConfiguration() ?&gt;\n                                    }\n                                }\n                            }\n                        }\n                    &lt;\/script&gt;<\/pre>\n\n\n\n<p><strong>Step 7:<\/strong> Create a <a href=\"https:\/\/webkul.com\/blog\/magento2-custom-option-template\/\">custom template<\/a> file which is mentioned in getDefaultConfiguration() method of <strong>Step 5<\/strong>,<strong> view\/adminhtml\/web\/template\/filterselect.html<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;div\n class=&quot;admin__action-multiselect-wrap action-select-wrap&quot;\n tabindex=&quot;0&quot;\n data-bind=&quot;\n attr: {\n     id: uid\n },\n css: {\n     _active: listVisible,\n     &#039;admin__action-multiselect-tree&#039;: isTree()\n },\n event: {\n     focusin: onFocusIn,\n     focusout: onFocusOut,\n     keydown: keydownSwitcher\n },\n outerClick: outerClick.bind($data)\n &quot;&gt;\n   &lt;!-- ko if: (!hasData() &amp;&amp; multiple) --&gt;\n   &lt;input type=&quot;hidden&quot;\n   data-bind=&quot;\n   attr: {\n       id: elementData.id,\n       name: elementData.name+&#039;&#091;]&#039;,\n       value: null\n   }\n &quot;&gt;\n  &lt;!-- \/ko --&gt;\n &lt;!-- ko ifnot: chipsEnabled --&gt;\n &lt;div\n     class=&quot;action-select admin__action-multiselect&quot;\n     data-role=&quot;advanced-select&quot;\n     data-bind=&quot;\n     css: {_active: multiselectFocus},\n     click: function(data, event) {\n         toggleListVisible(data, event)\n     }\n &quot;&gt;\n &lt;div class=&quot;admin__action-multiselect-text&quot;\n      data-role=&quot;selected-option&quot;\n      data-bind=&quot;text: setCaption()&quot;&gt;\n &lt;\/div&gt;\n&lt;!-- ko foreach: { data: getSelected(), as: &#039;option&#039;}  --&gt;\n&lt;input type=&quot;hidden&quot;\n    data-bind=&quot;\n    attr: {\n        id: $parent.elementData.id + value,\n        name: $parent.elementData.name +&#039;&#091;]&#039;,\n        value: value\n    }\n&quot;&gt;\n&lt;!-- \/ko --&gt;\n &lt;\/div&gt;\n &lt;!-- \/ko --&gt;\n &lt;!-- ko if: chipsEnabled --&gt;\n &lt;div\n     class=&quot;action-select admin__action-multiselect&quot;\n     data-role=&quot;advanced-select&quot;\n     data-bind=&quot;\n     css: {_active: multiselectFocus},\n     click: function(data, event) {\n         toggleListVisible(data, event)\n     }\n &quot;&gt;\n &lt;div class=&quot;admin__action-multiselect-text&quot;\n      data-bind=&quot;\n         visible: !hasData(),\n         i18n: selectedPlaceholders.defaultPlaceholder\n &quot;&gt;\n &lt;\/div&gt;\n &lt;!-- ko foreach: { data: getSelected(), as: &#039;option&#039;}  --&gt;\n     &lt;span class=&quot;admin__action-multiselect-crumb&quot;&gt;\n         &lt;span data-bind=&quot;text: label&quot;&gt;\n         &lt;\/span&gt;\n         &lt;button\n                 class=&quot;action-close&quot;\n                 type=&quot;button&quot;\n                 data-action=&quot;remove-selected-item&quot;\n                 tabindex=&quot;-1&quot;\n                 data-bind=&quot;click: $parent.removeSelected.bind($parent, value)\n         &quot;&gt;\n             &lt;span class=&quot;action-close-text&quot; translate=&quot;&#039;Close&#039;&quot;&gt;&lt;\/span&gt;\n         &lt;\/button&gt;\n     &lt;\/span&gt;\n     &lt;input type=&quot;hidden&quot;\n         data-bind=&quot;\n         attr: {\n             id: $parent.elementData.id + value,\n             name: $parent.elementData.name +&#039;&#091;]&#039;,\n             value: value\n         }\n     &quot;&gt;\n &lt;!-- \/ko --&gt;\n &lt;\/div&gt;\n &lt;!-- \/ko --&gt;\n &lt;div class=&quot;action-menu&quot;\n  data-bind=&quot;css: { _active: listVisible }\n &quot;&gt;\n &lt;!-- ko if: filterOptions --&gt;\n &lt;div class=&quot;admin__action-multiselect-search-wrap&quot;&gt;\n     &lt;input\n             class=&quot;admin__control-text admin__action-multiselect-search&quot;\n             data-role=&quot;advanced-select-text&quot;\n             type=&quot;text&quot;\n             data-bind=&quot;\n         event: {\n             keydown: filterOptionsKeydown\n         },\n         attr: {id: uid+2},\n         valueUpdate: &#039;afterkeydown&#039;,\n         value: filterInputValue,\n         hasFocus: filterOptionsFocus\n         &quot;&gt;\n     &lt;label\n             class=&quot;admin__action-multiselect-search-label&quot;\n             data-action=&quot;advanced-select-search&quot;\n             data-bind=&quot;attr: {for: uid+2}\n     &quot;&gt;\n     &lt;\/label&gt;\n     &lt;div if=&quot;itemsQuantity&quot;\n          data-bind=&quot;text: itemsQuantity&quot;\n          class=&quot;admin__action-multiselect-search-count&quot;&gt;\n     &lt;\/div&gt;\n &lt;\/div&gt;\n &lt;!-- \/ko --&gt;\n &lt;ul class=&quot;admin__action-multiselect-menu-inner _root&quot;\n     data-bind=&quot;\n         event: {\n            scroll: function(data, event){onScrollDown($data, event)}\n         }\n     &quot;&gt;\n     &lt;!-- ko foreach: { data: options, as: &#039;option&#039;}  --&gt;\n     &lt;li class=&quot;admin__action-multiselect-menu-inner-item _root&quot;\n         data-bind=&quot;css: { _parent: $data.optgroup }&quot;\n         data-role=&quot;option-group&quot;&gt;\n         &lt;div class=&quot;action-menu-item&quot;\n              data-bind=&quot;\n                 css: {\n                     _selected: $parent.isSelected(option.value),\n                     _hover: $parent.isHovered(option, $element),\n                     _expended: $parent.getLevelVisibility($data),\n                     _unclickable: $parent.isLabelDecoration($data),\n                     _last: $parent.addLastElement($data),\n                     &#039;_with-checkbox&#039;: $parent.showCheckbox\n                 },\n                 click: function(data, event){\n                     $parent.toggleOptionSelected($data, event);\n                 },\n                 clickBubble: false\n         &quot;&gt;\n             &lt;!-- ko if: $data.optgroup &amp;&amp; $parent.showOpenLevelsActionIcon--&gt;\n             &lt;div class=&quot;admin__action-multiselect-dropdown&quot;\n                  data-bind=&quot;\n                     click: function(event){\n                         $parent.openChildLevel($data, $element, event);\n                     },\n                     clickBubble: false\n                  &quot;&gt;\n             &lt;\/div&gt;\n             &lt;!-- \/ko--&gt;\n             &lt;!--ko if: $parent.showCheckbox--&gt;\n             &lt;input\n                     class=&quot;admin__control-checkbox&quot;\n                     type=&quot;checkbox&quot;\n                     tabindex=&quot;-1&quot;\n                     data-bind=&quot;attr: { &#039;checked&#039;: $parent.isSelected(option.value) }&quot;&gt;\n             &lt;!-- \/ko--&gt;\n             &lt;label class=&quot;admin__action-multiselect-label&quot;&gt;\n                 &lt;span data-bind=&quot;text: option.label&quot;&gt;&lt;\/span&gt;\n                 &lt;span\n                         if=&quot;$parent.getPath(option)&quot;\n                         class=&quot;admin__action-multiselect-item-path&quot;\n                         data-bind=&quot;text: $parent.getPath(option)&quot;&gt;&lt;\/span&gt;\n             &lt;\/label&gt;\n         &lt;\/div&gt;\n         &lt;!-- ko if: $data.optgroup --&gt;\n         &lt;!-- ko template: {name: $parent.optgroupTmpl, data: {root: $parent, current: $data}} --&gt;\n         &lt;!-- \/ko --&gt;\n         &lt;!-- \/ko--&gt;\n     &lt;\/li&gt;\n     &lt;!-- \/ko --&gt;\n &lt;\/ul&gt;\n &lt;!-- ko if: $data.closeBtn --&gt;\n &lt;div class=&quot;admin__action-multiselect-actions-wrap&quot;&gt;\n     &lt;button class=&quot;action-default&quot;\n             data-action=&quot;close-advanced-select&quot;\n             type=&quot;button&quot;\n             data-bind=&quot;click: outerClick&quot;&gt;\n         &lt;span translate=&quot;closeBtnLabel&quot;&gt;&lt;\/span&gt;\n     &lt;\/button&gt;\n &lt;\/div&gt;\n &lt;!-- \/ko --&gt;\n &lt;\/div&gt;\n &lt;\/div&gt;\n  &lt;!-- ko if: ($data.getSelected().length == 0 &amp;&amp; required_entry) --&gt;\n  &lt;input type=&quot;hidden&quot;\n  data-bind=&quot;\n  attr: {\n    name: &#039;custom_required&#039;,\n    class: &#039;required-entry&#039;,\n    value: null\n  }\n&quot;&gt;\n &lt;!-- \/ko --&gt;<\/pre>\n\n\n\n<p><strong>Step 8:<\/strong> Create a block file for form, <strong>Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit\\Form.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit;\n\nclass Form extends \\Magento\\Backend\\Block\\Widget\\Form\\Generic\n{\n    \/**\n     * Init form\n     *\n     * @return void\n     *\/\n    protected function _construct()\n    {\n        parent::_construct();\n        $this-&gt;setId(&#039;blog_account_form&#039;);\n        $this-&gt;setTitle(__(&#039;Blog Account Information&#039;));\n    }\n\n    \/**\n     * Prepare form\n     *\n     * @return $this\n     *\/\n    protected function _prepareForm()\n    {\n        $model = $this-&gt;_coreRegistry-&gt;registry(&#039;business_list_model&#039;);\n        $form = $this-&gt;_formFactory-&gt;create(\n            &#091;\n                &#039;data&#039; =&gt; &#091;\n                    &#039;id&#039; =&gt; &#039;edit_form&#039;,\n                    &#039;enctype&#039; =&gt; &#039;multipart\/form-data&#039;,\n                    &#039;action&#039; =&gt; $this-&gt;getData(&#039;action&#039;),\n                    &#039;method&#039; =&gt; &#039;post&#039;\n                ]\n            ]\n        );\n        if (!empty($model-&gt;getData())) {\n            $data = $model-&gt;getData();\n            if (isset($data&#091;&#039;access_data&#039;])) {\n                $data&#091;&#039;access_data&#039;] = explode(&#039;,&#039;, $data&#091;&#039;access_data&#039;] ?? &#039;&#039;);\n            }\n            $form-&gt;setValues($data);\n        }\n        $form-&gt;setUseContainer(true);\n        $this-&gt;setForm($form);\n        return parent::_prepareForm();\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 9:<\/strong> Create a controller file for layout <strong>webkulblog_account_edit.xml<\/strong> , <strong>Webkul\\Custom\\Controller\\Adminhtml\\Account\\Edit.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Controller\\Adminhtml\\Account;\n\nuse Magento\\Framework\\Controller\\ResultFactory;\nuse Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit as AccountEdit;\nuse Webkul\\Custom\\Block\\Adminhtml\\Account\\Edit\\Tabs;\n\nclass Edit extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * @var string\n     *\/\n    public const ADMIN_RESOURCE = &quot;Webkul_Custom::accountedit&quot;;\n\n    \/**\n     * @var \\Magento\\Framework\\Registry\n     *\/\n    private $registry;\n\n    \/**\n     * @var \\Webkul\\Custom\\Model\\BusinessListFactory\n     *\/\n    protected $businessListFactory;\n\n    \/**\n     * @param \\Magento\\Backend\\App\\Action\\Context $context\n     * @param \\Magento\\Framework\\Registry $registry\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Framework\\Registry $registry,\n        \\Webkul\\Custom\\Model\\BusinessListFactory $businessListFactory\n    ) {\n        $this-&gt;registry = $registry;\n        $this-&gt;businessListFactory = $businessListFactory;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Execute\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Page\n     *\/\n    public function execute()\n    {\n        try {\n            $params = $this-&gt;getRequest()-&gt;getParams();\n            $businessListModel = $this-&gt;businessListFactory-&gt;create();\n            if (isset($params&#091;&#039;entity_id&#039;]) &amp;&amp; $params&#091;&#039;entity_id&#039;]) {\n                $businessListModel-&gt;load($params&#091;&#039;entity_id&#039;]);\n                if (!$businessListModel-&gt;getId()) {\n                    $this-&gt;messageManager-&gt;addError(__(&#039;Requested account currently not available.&#039;));\n                    $resultRedirect = $this-&gt;resultRedirectFactory-&gt;create();\n                    return $resultRedirect-&gt;setPath(&#039;*\/*\/&#039;);\n                }\n            }\n            $this-&gt;registry-&gt;register(&#039;business_list_model&#039;, $businessListModel);\n            $resultPage = $this-&gt;resultFactory-&gt;create(ResultFactory::TYPE_PAGE);\n            $resultPage-&gt;setActiveMenu(&#039;Webkul_Custom::webkulblog&#039;);\n            $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;prepend(__(&#039;Account&#039;));\n            $resultPage-&gt;addContent($resultPage-&gt;getLayout()-&gt;createBlock(AccountEdit::class));\n            $resultPage-&gt;addLeft($resultPage-&gt;getLayout()-&gt;createBlock(Tabs::class));\n            return $resultPage;\n        } catch (\\Exception $e) {\n            $this-&gt;messageManager-&gt;addError($e-&gt;getMessage());\n            $this-&gt;_redirect(&#039;*\/*\/&#039;);\n        }\n    }\n    \/**\n     * Check for is allowed\n     *\n     * @return boolean\n     *\/\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(self::ADMIN_RESOURCE);\n    }\n}<\/pre>\n\n\n\n<p><strong>Step 10:<\/strong> Create a controller file for the save selected option, <strong>Webkul\\Custom\\Controller\\Adminhtml\\Account\\Save.php<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_Custom\n * @author    Webkul\n * @copyright Copyright (c)  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\nnamespace Webkul\\Custom\\Controller\\Adminhtml\\Account;\n\nuse Magento\\Backend\\App\\Action;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Framework\\View\\Result\\PageFactory;\n\nclass Save extends Action\n{\n    \/**\n     * @var Magento\\Framework\\View\\Result\\PageFactory\n     *\/\n    protected $resultPageFactory;\n\n    \/**\n     * @var Webkul\\Custom\\Model\\BusinessListFactory *\/\n    protected $businessListFactory;\n\n    \/**\n     * @var \\Magento\\Framework\\Registry\n     *\/\n    protected $coreRegistry = null;\n\n    \/**\n     * @param Context $context\n     * @param PageFactory $resultPageFactory\n     * @param \\Webkul\\Custom\\Model\\BusinessListFactory $businessListFactory\n     * @param \\Magento\\Framework\\Registry $coreRegistry\n     *\/\n    public function __construct(\n        Context $context,\n        PageFactory $resultPageFactory,\n        \\Webkul\\Custom\\Model\\BusinessListFactory $businessListFactory,\n        \\Magento\\Framework\\Registry $coreRegistry\n    ) {\n        parent::__construct($context);\n        $this-&gt;resultPageFactory = $resultPageFactory;\n        $this-&gt;businessListFactory = $businessListFactory;\n        $this-&gt;coreRegistry = $coreRegistry;\n    }\n\n    \/**\n     * Save User Data\n     *\n     * @return \\Magento\\Framework\\App\\Response\\Http\n     *\/\n    public function execute()\n    {\n        $resultRedirect = $this-&gt;resultRedirectFactory-&gt;create();\n        $data = $this-&gt;getRequest()-&gt;getParams();\n        if (isset($data&#091;&#039;user_name&#039;])) {\n            $userAcccessIds = &#039;&#039;;\n            if (isset($data&#091;&#039;access_data&#039;])) {\n                $userAcccessIds = implode(&#039;,&#039;, $data&#091;&#039;access_data&#039;]);\n            }\n            $data&#091;&#039;access_data&#039;] = $userAcccessIds;\n            $businessList = $this-&gt;businessListFactory-&gt;create();\n            $businessList-&gt;setData($data)-&gt;save();\n            $id = $businessList-&gt;getId();\n            $this-&gt;coreRegistry-&gt;register(&quot;entity_id&quot;, $id);\n            $this-&gt;messageManager-&gt;addSuccess(&quot;User data has been saved.&quot;);\n            return $resultRedirect-&gt;setPath(&#039;*\/*\/edit&#039;, &#091;&#039;entity_id&#039; =&gt; $id]);\n        } else {\n            $this-&gt;messageManager-&gt;addError(\n                __(&#039;Something went wrong while saving the user data.&#039;)\n            );\n            return $resultRedirect-&gt;setPath(&#039;*\/*\/edit&#039;);\n        }\n    }\n}<\/pre>\n\n\n\n<p>After this, a ui-select with a search filter using the block method will be displayed on your form.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"670\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png\" alt=\"Screenshot-2024-01-23T201658.071\" class=\"wp-image-419201\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-300x167.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-250x139.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-768x428.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071.png 1398w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Change custom type UI select  element configuration in <strong>Step 4<\/strong>: <\/p>\n\n\n\n<p><strong>Note:<\/strong>  Custom field element configuration changed according to the mentioned configuration in <strong>getDefaultConfiguration()<\/strong> method of <strong>Step 5<\/strong> file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\"> $fieldset-&gt;addField(\n            &#039;access_data&#039;, \/\/Element Id\n            &#039;filterselect&#039;, \/\/custom type\n            &#091;\n                &#039;name&#039; =&gt; &#039;access_data&#039;,\n                &#039;label&#039; =&gt; __(&#039;Access data&#039;),\n                &#039;options&#039; =&gt; $this-&gt;getOptions(),\n                &#039;multiple&#039; =&gt; true,\n                &#039;required&#039; =&gt; true,\n            ] \/\/ In array mentioned configuration of element\n        );<\/pre>\n\n\n\n<p>Meanwhile Please try the above example and If you have any Queries then please ask in the comment section below.<\/p>\n\n\n\n<p>Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here we learn how to add or create a UI-Select field using the block method on the Admin form. Let\u2019s start step by step.You must have installed Magento 2 custom Module on which you are going to implement this. Step 1: We need to create the layout file to define the admin form in view\/adminhtml\/layout\/webkulblog_account_edit.xml <a href=\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":590,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[15264,3307,2070,15261,15263],"class_list":["post-419178","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-blog-form","tag-custom-type-field-in-form-magento-2","tag-magento2","tag-ui-select","tag-ui-select-with-filter-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add UI-Select with search filter using the block method<\/title>\n<meta name=\"description\" content=\"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add UI-Select with search filter using the block method\" \/>\n<meta property=\"og:description\" content=\"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-25T06:35:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-10T06:07:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png\" \/>\n<meta name=\"author\" content=\"Nitish Kumar Upadhyay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nitish Kumar Upadhyay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\"},\"author\":{\"name\":\"Nitish Kumar Upadhyay\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/dc2d643eb440a59aa7d72c1150b9ed09\"},\"headline\":\"Add UI-Select with search filter using the block method on the Admin form in Magento 2\",\"datePublished\":\"2024-01-25T06:35:34+00:00\",\"dateModified\":\"2024-07-10T06:07:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\"},\"wordCount\":292,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png\",\"keywords\":[\"Blog Form\",\"custom type field in form magento 2\",\"Magento2\",\"ui select\",\"Ui Select with filter\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\",\"name\":\"Add UI-Select with search filter using the block method\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png\",\"datePublished\":\"2024-01-25T06:35:34+00:00\",\"dateModified\":\"2024-07-10T06:07:22+00:00\",\"description\":\"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071.png\",\"width\":1398,\"height\":780,\"caption\":\"Screenshot-2024-01-23T201658.071\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add UI-Select with search filter using the block method on the Admin form in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/dc2d643eb440a59aa7d72c1150b9ed09\",\"name\":\"Nitish Kumar Upadhyay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/54d626b859687e935e7a2e6cee7e868245ab9b8d61c3961401c5ce665bbcc6b1?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/54d626b859687e935e7a2e6cee7e868245ab9b8d61c3961401c5ce665bbcc6b1?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Nitish Kumar Upadhyay\"},\"description\":\"Nitish, a skilled Software Engineer, excels in Magento Commerce B2B development. Expertise in crafting custom solutions, optimizing workflows, and integrating seamless eCommerce features drives business growth and operational efficiency.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/nitishkumar-upadhyay742\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add UI-Select with search filter using the block method","description":"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Add UI-Select with search filter using the block method","og_description":"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.","og_url":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2024-01-25T06:35:34+00:00","article_modified_time":"2024-07-10T06:07:22+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png","type":"","width":"","height":""}],"author":"Nitish Kumar Upadhyay","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Nitish Kumar Upadhyay","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/"},"author":{"name":"Nitish Kumar Upadhyay","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/dc2d643eb440a59aa7d72c1150b9ed09"},"headline":"Add UI-Select with search filter using the block method on the Admin form in Magento 2","datePublished":"2024-01-25T06:35:34+00:00","dateModified":"2024-07-10T06:07:22+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/"},"wordCount":292,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png","keywords":["Blog Form","custom type field in form magento 2","Magento2","ui select","Ui Select with filter"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/","url":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/","name":"Add UI-Select with search filter using the block method","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071-1200x670.png","datePublished":"2024-01-25T06:35:34+00:00","dateModified":"2024-07-10T06:07:22+00:00","description":"Here we learn how to add or create a UI-Select field using the block method on the Admin form in Magento 2.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-23T201658.071.png","width":1398,"height":780,"caption":"Screenshot-2024-01-23T201658.071"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/add-ui-select-with-search-filter-using-the-block-method-on-the-admin-form-in-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add UI-Select with search filter using the block method on the Admin form in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/dc2d643eb440a59aa7d72c1150b9ed09","name":"Nitish Kumar Upadhyay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/54d626b859687e935e7a2e6cee7e868245ab9b8d61c3961401c5ce665bbcc6b1?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/54d626b859687e935e7a2e6cee7e868245ab9b8d61c3961401c5ce665bbcc6b1?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Nitish Kumar Upadhyay"},"description":"Nitish, a skilled Software Engineer, excels in Magento Commerce B2B development. Expertise in crafting custom solutions, optimizing workflows, and integrating seamless eCommerce features drives business growth and operational efficiency.","url":"https:\/\/webkul.com\/blog\/author\/nitishkumar-upadhyay742\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/419178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/590"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=419178"}],"version-history":[{"count":19,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/419178\/revisions"}],"predecessor-version":[{"id":452217,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/419178\/revisions\/452217"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=419178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=419178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=419178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}