{"id":7943,"date":"2015-09-01T17:57:30","date_gmt":"2015-09-01T14:57:30","guid":{"rendered":"http:\/\/blog.belvg.com\/?p=7943"},"modified":"2025-06-26T21:58:04","modified_gmt":"2025-06-26T19:58:04","slug":"creating-a-custom-field-in-magento-2-0-module-settings","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html","title":{"rendered":"Creating a Custom Field in Magento 2.0 Module Settings"},"content":{"rendered":"\n<p align=\"left\">Very often, to save some module settings we have to create and use custom fields for the module settings page.&nbsp; To demonstrate the case, let&rsquo;s take multiselect sorting as an example, which is used in our module <strong>BelVG_Pri<\/strong><strong>&#1089;<\/strong><strong>elist<\/strong> for sorting attributes. We are going to use <a href=\"https:\/\/jqueryui.com\/\">jQuery UI<\/a> as a supplementary library, specifically, the part which is responsible for sorting.<!--more--><\/p>\n<p align=\"left\">In the first place we create a custom field for the module settings in the admin panel.<\/p>\n<p>File app\\code\\BelVG\\Pricelist\\etc\\adminhtml\\system.xml:<\/p>\n<pre class=\"lang:php decode:true\">----------------------------------------------------------------------\r\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n...\r\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"..\/..\/..\/Config\/etc\/system_file.xsd\"&gt;\r\n    &lt;system&gt;\r\n        &hellip;\r\n        &lt;section id=\"pricelist\" translate=\"label\" sortOrder=\"140\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n            &hellip;\r\n            &lt;group id=\"content\" translate=\"label\" type=\"text\" sortOrder=\"20\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n            &hellip;\r\n                &lt;field id=\"attributes\" translate=\"label\" type=\"text\" sortOrder=\"10\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n                    &lt;label&gt;Additional Attributes&lt;\/label&gt;\r\n                    &lt;source_model&gt;BelVG\\Pricelist\\Model\\Config\\Source\\Attributes&lt;\/source_model&gt;\r\n                    &lt;frontend_model&gt;BelVG\\Pricelist\\Block\\System\\Config\\Form\\Field\\Attributes&lt;\/frontend_model&gt;\r\n                &lt;\/field&gt;\r\n            &lt;\/group&gt;\r\n        &lt;\/section&gt;\r\n    &lt;\/system&gt;\r\n&lt;\/config&gt;<\/pre>\n<p align=\"left\">Key nodes here are <strong>s<\/strong><strong>&#1086;<\/strong><strong>ur<\/strong><strong>&#1089;<\/strong><strong>e_m<\/strong><strong>&#1086;<\/strong><strong>del<\/strong> <strong>and fr<\/strong><strong>&#1086;<\/strong><strong>ntend_m<\/strong><strong>&#1086;<\/strong><strong>del<\/strong> and the parameter <strong>type<\/strong> in the <strong>field<\/strong> node:<\/p>\n<ul>\n<li>S&#1086;ur&#1089;e_m&#1086;del &ndash; determines values for multiselect;<\/li>\n<li>Fr&#1086;ntend_m&#1086;del &ndash; defines the layout of the field;<\/li>\n<li>Type &ndash; determines the type of the source element which we are going to extend;<\/li>\n<li>Source_model &ndash; this one is quite simple: here we fetch the required attributes and pass as an array with the method toOptionArray().<\/li>\n<\/ul>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/magento-audit\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Audit<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento Audit<\/p><a href=\"https:\/\/belvg.com\/magento-audit\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<p>File app\\code\\BelVG\\Pricelist\\Model\\Config\\Source\\Attributes.php (DOWNLOAD):<\/p>\n<pre class=\"lang:php decode:true\">-------------------------------------------------------------------------------------------------------\r\n&lt;?php\r\nnamespace BelVG\\Pricelist\\Model\\Config\\Source;\r\nclass Attributes implements \\Magento\\Framework\\Option\\ArrayInterface\r\n{\r\n    protected $_entityType;\r\n    protected $_store;\r\n\r\n    public function __construct(\r\n        \\Magento\\Store\\Model\\Store $store,\r\n        \\Magento\\Eav\\Model\\Entity\\Type $entityType\r\n    ) {\r\n        $this-&gt;_store = $store;\r\n        $this-&gt;_entityType = $entityType;\r\n    }\r\n\r\n    public function toOptionArray()\r\n    {\r\n        $types = array('text', 'select', 'decimal');\r\n        $attributes = $this-&gt;_entityType-&gt;loadByCode('catalog_product')-&gt;getAttributeCollection();\r\n        $attributes-&gt;addFieldToFilter('frontend_input', $types);\r\n\r\n        $result = array();\r\n        foreach ($attributes as $attr) {\r\n            if ($attr-&gt;getFrontendLabel()) {\r\n                $result[] = array('value' =&gt; $attr-&gt;getAttributeId(), 'label' =&gt; $attr-&gt;getFrontendLabel(), 'title' =&gt; $attr-&gt;getAttributeCode());\r\n            }\r\n        }\r\n\r\n        return $result;\r\n    }\r\n\r\n}<\/pre>\n<p>Lets have a closer look at the class fr&#1086;ntend_m&#1086;del. The basic idea is to extend the original element (type = text) and to add additional elements into js code. We will use the same b&#1072;&#1089;kend_m&#1086;del for saving values&nbsp; &ndash; in our case this is ( ).<\/p>\n<p>File app\\code\\BelVG\\Pricelist\\Block\\System\\Config\\Form\\Field\\Attributes.php (DOWNLOAD):<\/p>\n<pre class=\"lang:php decode:true\">---------------------------------------------------------------------------------------------------------------------\r\n&lt;?php\r\nnamespace BelVG\\Pricelist\\Block\\System\\Config\\Form\\Field;\r\nuse Magento\\Framework\\Data\\Form\\Element\\AbstractElement;\r\n\r\nclass Attributes extends \\Magento\\Config\\Block\\System\\Config\\Form\\Field\r\n{\r\n    protected function _getElementHtml(AbstractElement $element)\r\n    {\r\n        $values = $element-&gt;getValues();\r\n        $html = '&lt;table id=\"' . $element-&gt;getId() . '_table\" class=\"ui_select_table\" cellspacing=\"0\"&gt;';\r\n        $html .= '&lt;tbody&gt;&lt;tr&gt;';\r\n        $html .= '&lt;td&gt;&lt;ul id=\"' . $element-&gt;getId() . '_selected\" class=\"ui_select selected sortable\"&gt;';\r\n\r\n        $selected = explode(',', $element-&gt;getValue());\r\n        foreach ($selected as $value) {\r\n            if ($key = array_search($value, array_column($values, 'value'))) {\r\n                $html .= '&lt;li value=\"' . $value . '\" title=\"' . $values[$key]['title'] . '\"&gt;';\r\n                $html .= isset($values[$key]['label'])?$values[$key]['label']:'n\/a';\r\n                $html .= '&lt;\/li&gt;';\r\n                $values[$key]['selected'] = TRUE;\r\n            }\r\n        }\r\n\r\n        $html .= '&lt;\/ul&gt;&lt;\/td&gt;&lt;td&gt;';\r\n        $html .= '&lt;ul id=\"' . $element-&gt;getId() . '_source\" class=\"ui_select source sortable\"&gt;';\r\n        if ($values) {\r\n            foreach ($values as $option) {\r\n                if (!isset($option['selected'])) {\r\n                    $html .= '&lt;li value=\"' . $option['value'] . '\" title=\"' . $option['title'] . '\"&gt;';\r\n                    $html .= isset($option['label'])?$option['label']:'n\/a';\r\n                    $html .= '&lt;\/li&gt;';\r\n                }\r\n            }\r\n        }\r\n\r\n        $html .= '&lt;\/ul&gt;&lt;\/td&gt;&lt;\/tr&gt;&lt;\/tbody&gt;&lt;\/table&gt;';\r\n        $html .= '&lt;div style=\"display:none;\"&gt;' . $element-&gt;getElementHtml() . '&lt;\/div&gt;';\r\n        $html .= '&lt;script type=\"text\/javascript\"&gt;\r\n                require([\"jquery\"], function(jQuery){\r\n                    require([\"BelVG_Pricelist\/js\/verpage\", \"ui\/1.11.4\"], function(){\r\n                        jQuery(document).ready( function() {\r\n                            jQuery(\"#' . $element-&gt;getId() . '_selected, #' . $element-&gt;getId() . '_source\").sortable({\r\n                                connectWith: \".sortable\",\r\n                                stop: function(event, ui) {\r\n                                    var vals = [];\r\n                                    jQuery(\"#' . $element-&gt;getId() . '_selected\").find(\"li\").each(function(index, element){\r\n                                        vals.push(jQuery(element).val());\r\n                                    });\r\n                                    jQuery(\"#' . $element-&gt;getId() . '\").val(vals);                                    \r\n                                }\r\n                            }).disableSelection();\r\n                        });\r\n                    })\r\n                })\r\n                &lt;\/script&gt;';\r\n\r\n        return $html;\r\n    }\r\n}<\/pre>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/migration-to-magento-2.png\" width=\"100\" height=\"100\" alt=\"migration to magento 2\" class=\"module_image\" title=\"Creating a Custom Field in Magento 2.0 Module Settings\"><div class=\"module_content_part\"><h3 class=\"title\">Magento 2 Migration<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento 2 Migration<\/p><a href=\"https:\/\/belvg.com\/migration-to-magento-2\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the page<\/span><\/a><\/div><\/div><\/div>\n<p>Basically, it is enough to override only the method _getElementHtml() in our case. But for more complex custom fields you may need to override some other methods too. To connect an additional js library it should be added to requirejs-config.js under app\/code\/BelVG\/Pricelist\/view\/&#1072;dminhtml:<\/p>\n<p>File app\/code\/BelVG\/Pricelist\/view\/adminhtml\/requirejs-config.js:<\/p>\n<pre class=\"lang:php decode:true\">---------------------------------------------------------------------------------------------------------------------\r\n\r\nvar config = {\r\n    map: {\r\n        '*': {\r\n            'ui\/1.11.4': 'BelVG_Pricelist\/jqueryext\/ui\/1.11.4\/jquery-ui'\r\n        }\r\n    }\r\n};<\/pre>\n<p>Also place the library file into the folder: app\/code\/BelVG\/Pricelist\/view\/adminhtml\/web\/jqueryext\/ui\/1.11.4\/ jquery-ui.js<\/p>\n<p>So now we have a custom element where you can select and sort elements (in the demonstrated case these are attributes):<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"lazy aligncenter wp-image-10025 size-belvg-post-content\" src=\"https:\/\/belvg.com\/wp-content\/uploads\/2019\/06\/pixel.png\" data-src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/09\/55652-clip-80kb-850x401.png\" alt=\"55652 clip 80kb 850x401\" width=\"850\" height=\"401\" title=\"Creating a Custom Field in Magento 2.0 Module Settings\"><\/p>\n<p>It is possible to use this element in any project or module practically unchanged.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/store.belvg.com\/\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2019\/06\/Magento-store.belvg_.com_.png\" width=\"481\" height=\"480\" alt=\"Magento store.belvg.com\" class=\"module_image\" title=\"Creating a Custom Field in Magento 2.0 Module Settings\"><div class=\"module_content_part\"><h3 class=\"title\">Magento Extensions<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG Magento extensions<\/p><a href=\"https:\/\/store.belvg.com\/\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the store<\/span><\/a><\/div><\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"Very often, to save some module settings we have to create and use custom fields &#8230;","protected":false},"author":30,"featured_media":10024,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,389],"tags":[424,3,382],"class_list":["post-7943","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-magento","category-magento2-development","tag-custom-field","tag-magento","tag-magento-2-0","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Very often, to save some module settings we have to create and use custom fields for the module settings page. To demonstrate the case, let\u2019s take multiselect sorting as an example, which is used in our module BelVG_Pri\u0441elist for sorting attributes.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrei Danilchyk\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#article\",\"name\":\"Creating a Custom Field in M\\u0430gent\\u043e 2.0 Module Settings | BelVG Blog\",\"headline\":\"Creating a Custom Field in Magento 2.0 Module Settings\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrei-danilchyk#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/blog-mage0109.jpg\",\"width\":682,\"height\":170},\"datePublished\":\"2015-09-01T17:57:30+02:00\",\"dateModified\":\"2025-06-26T21:58:04+02:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage\"},\"articleSection\":\"Magento, Magento 2 Development, Custom Field, magento, magento 2.0, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"position\":2,\"name\":\"Magento\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#listItem\",\"name\":\"Creating a Custom Field in Magento 2.0 Module Settings\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#listItem\",\"position\":3,\"name\":\"Creating a Custom Field in Magento 2.0 Module Settings\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento#listItem\",\"name\":\"Magento\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrei-danilchyk#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrei-danilchyk\",\"name\":\"Andrei Danilchyk\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/035c7a3d986ac8d09b60f02a1d47ab8822a92657f10160d588ea28f14db1efb7?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrei Danilchyk\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html\",\"name\":\"Creating a Custom Field in M\\u0430gent\\u043e 2.0 Module Settings | BelVG Blog\",\"description\":\"Very often, to save some module settings we have to create and use custom fields for the module settings page. To demonstrate the case, let\\u2019s take multiselect sorting as an example, which is used in our module BelVG_Pri\\u0441elist for sorting attributes.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrei-danilchyk#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrei-danilchyk#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/09\\\/blog-mage0109.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html\\\/#mainImage\",\"width\":682,\"height\":170},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/creating-a-custom-field-in-magento-2-0-module-settings.html#mainImage\"},\"datePublished\":\"2015-09-01T17:57:30+02:00\",\"dateModified\":\"2025-06-26T21:58:04+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Creating a Custom Field in M\u0430gent\u043e 2.0 Module Settings | BelVG Blog","description":"Very often, to save some module settings we have to create and use custom fields for the module settings page. To demonstrate the case, let\u2019s take multiselect sorting as an example, which is used in our module BelVG_Pri\u0441elist for sorting attributes.","canonical_url":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#article","name":"Creating a Custom Field in M\u0430gent\u043e 2.0 Module Settings | BelVG Blog","headline":"Creating a Custom Field in Magento 2.0 Module Settings","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrei-danilchyk#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/09\/blog-mage0109.jpg","width":682,"height":170},"datePublished":"2015-09-01T17:57:30+02:00","dateModified":"2025-06-26T21:58:04+02:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage"},"articleSection":"Magento, Magento 2 Development, Custom Field, magento, magento 2.0, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","position":2,"name":"Magento","item":"https:\/\/belvg.com\/blog\/category\/magento","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#listItem","name":"Creating a Custom Field in Magento 2.0 Module Settings"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#listItem","position":3,"name":"Creating a Custom Field in Magento 2.0 Module Settings","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento#listItem","name":"Magento"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrei-danilchyk#author","url":"https:\/\/belvg.com\/blog\/author\/andrei-danilchyk","name":"Andrei Danilchyk","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/035c7a3d986ac8d09b60f02a1d47ab8822a92657f10160d588ea28f14db1efb7?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrei Danilchyk"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#webpage","url":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html","name":"Creating a Custom Field in M\u0430gent\u043e 2.0 Module Settings | BelVG Blog","description":"Very often, to save some module settings we have to create and use custom fields for the module settings page. To demonstrate the case, let\u2019s take multiselect sorting as an example, which is used in our module BelVG_Pri\u0441elist for sorting attributes.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrei-danilchyk#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrei-danilchyk#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2015\/09\/blog-mage0109.jpg","@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html\/#mainImage","width":682,"height":170},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html#mainImage"},"datePublished":"2015-09-01T17:57:30+02:00","dateModified":"2025-06-26T21:58:04+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"7943","title":"Creating a Custom Field in M\u0430gent\u043e 2.0 Module Settings  | #site_title","description":"Very often, to save some module settings we have to create and use custom fields for the module settings page.  To demonstrate the case, let\u2019s take multiselect sorting as an example, which is used in our module BelVG_Pri\u0441elist for sorting attributes.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:52","updated":"2026-11-03 18:37:52"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento\" title=\"Magento\">Magento<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCreating a Custom Field in Magento 2.0 Module Settings\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento","link":"https:\/\/belvg.com\/blog\/category\/magento"},{"label":"Creating a Custom Field in Magento 2.0 Module Settings","link":"https:\/\/belvg.com\/blog\/creating-a-custom-field-in-magento-2-0-module-settings.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=7943"}],"version-history":[{"count":4,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7943\/revisions"}],"predecessor-version":[{"id":29631,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/7943\/revisions\/29631"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/10024"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=7943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=7943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=7943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}