{"id":81,"date":"2025-11-04T20:51:47","date_gmt":"2025-11-04T20:51:47","guid":{"rendered":"https:\/\/jaedpro.com\/wp-react-panel\/?post_type=docs&#038;p=81"},"modified":"2025-11-04T21:06:02","modified_gmt":"2025-11-04T21:06:02","password":"","slug":"field-type-select","status":"publish","type":"docs","link":"https:\/\/jaedpro.com\/wp-react-panel\/docs\/field-type-select\/","title":{"rendered":"Field Type: Select"},"content":{"rendered":"\n<p>A dropdown select field for choosing one or multiple options from a list.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example Usage<\/h3>\n\n\n\n<div class=\"betterdocs-code-snippet-wrapper theme-light betterdocs-code-snippet-68d9d9b3\"\n     id=\"betterdocs-code-snippet-68d9d9b3\"\n     data-language=\"php\"\n     data-copy-button=\"true\">\n\n            <div class=\"betterdocs-code-snippet-header betterdocs-file-preview-header\">\n        <div class=\"betterdocs-file-preview-left\">\n                            <div class=\"betterdocs-traffic-lights\">\n                    <span class=\"traffic-light traffic-light-red\"><\/span>\n                    <span class=\"traffic-light traffic-light-yellow\"><\/span>\n                    <span class=\"traffic-light traffic-light-green\"><\/span>\n                <\/div>\n            \n            <div class=\"betterdocs-file-info\">\n                \n                                    <div class=\"betterdocs-file-name\">\n                        <span class=\"file-name-text\">sample-plugin.php<\/span>\n                    <\/div>\n                            <\/div>\n        <\/div>\n\n        <div class=\"betterdocs-file-preview-right\">\n                            <div class=\"betterdocs-code-snippet-copy-container\">\n                    <button class=\"betterdocs-code-snippet-copy-button\"\n                            type=\"button\"\n                            data-clipboard-target=\"#betterdocs-code-snippet-68d9d9b3 .betterdocs-code-snippet-code code\"\n                            aria-label=\"Copy code to clipboard\">\n                        <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z\" fill=\"currentColor\"\/>\n                        <\/svg>\n                    <\/button>\n                                    <\/div>\n                    <\/div>\n        <\/div>\n    \n    <div class=\"betterdocs-code-snippet-content\">\n        \n        <pre class=\"betterdocs-code-snippet-code language-php\"><code>\/\/ Single Select Example\narray(\n\t&#039;id&#039;          =&gt; &#039;notification_method&#039;,\n\t&#039;title&#039;       =&gt; &#039;Notification Method&#039;,\n\t&#039;desc&#039;        =&gt; &#039;Choose how notifications should be delivered&#039;,\n\t&#039;type&#039;        =&gt; &#039;select&#039;,\n\t&#039;options&#039;     =&gt; array(\n\t\t&#039;email&#039; =&gt; &#039;Email&#039;,\n\t\t&#039;sms&#039;   =&gt; &#039;SMS&#039;,\n\t\t&#039;push&#039;  =&gt; &#039;Push Notification&#039;,\n\t),\n\t&#039;placeholder&#039; =&gt; &#039;Select method&#039;,\n\t&#039;default&#039;     =&gt; &#039;email&#039;,\n\t&#039;value&#039;       =&gt; get_option( &#039;notification_method&#039; ),\n),\n\n\n\/\/ Multiple Select Example\narray(\n\t&#039;id&#039;          =&gt; &#039;allowed_roles&#039;,\n\t&#039;title&#039;       =&gt; &#039;Allowed User Roles&#039;,\n\t&#039;desc&#039;        =&gt; &#039;Select which user roles can access the system&#039;,\n\t&#039;type&#039;        =&gt; &#039;select&#039;,\n\t&#039;options&#039;     =&gt; array(\n\t\t&#039;administrator&#039; =&gt; &#039;Administrator&#039;,\n\t\t&#039;editor&#039;        =&gt; &#039;Editor&#039;,\n\t\t&#039;author&#039;        =&gt; &#039;Author&#039;,\n\t),\n\t&#039;placeholder&#039; =&gt; &#039;Select user roles&#039;,\n\t&#039;multiple&#039;    =&gt; true,\n\t&#039;default&#039;     =&gt; array( &#039;administrator&#039;, &#039;editor&#039; ),\n\t&#039;value&#039;       =&gt; get_option( &#039;allowed_roles&#039; ),\n),<\/code><\/pre>\n    <\/div>\n<\/div>\n\n<script type=\"text\/javascript\">\ndocument.addEventListener('DOMContentLoaded', function() {\n    \/\/ Initialize copy functionality for this specific snippet\n    const snippet = document.getElementById('betterdocs-code-snippet-68d9d9b3');\n    if (snippet && window.BetterDocsCodeSnippet) {\n        window.BetterDocsCodeSnippet.initCopyButton(snippet);\n    }\n});\n<\/script>\n\n\n\n<h3 class=\"wp-block-heading\">Properties<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>id<\/strong> (required) &#8211; Unique identifier for the field<\/li>\n\n\n\n<li><strong>title<\/strong> (required) &#8211; Label displayed above the select field<\/li>\n\n\n\n<li><strong>desc<\/strong> (optional) &#8211; Help text shown below the field<\/li>\n\n\n\n<li><strong>type<\/strong> (required) &#8211; Must be <code>'select'<\/code><\/li>\n\n\n\n<li><strong>options<\/strong> (required) &#8211; Associative array of <code>value => label<\/code> pairs<\/li>\n\n\n\n<li><strong>placeholder<\/strong> (optional) &#8211; Placeholder text shown when no selection is made<\/li>\n\n\n\n<li><strong>multiple<\/strong> (optional) &#8211; Set to <code>true<\/code> to allow multiple selections (default: <code>false<\/code>)<\/li>\n\n\n\n<li><strong>default<\/strong> (optional) &#8211; Default value (string for single, array for multiple)<\/li>\n\n\n\n<li><strong>value<\/strong> (optional) &#8211; Current saved value(s)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Notes<\/h3>\n\n\n\n<p>When <code>multiple<\/code> is enabled, the field returns an array of selected values. For single select, it returns a string.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A dropdown select field for choosing one or multiple options from a list. Example Usage Properties Notes When multiple is enabled, the field returns an array of selected values. For single select, it returns a string.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[4],"doc_tag":[],"class_list":["post-81","docs","type-docs","status-publish","hentry","doc_category-field-types"],"blocksy_meta":[],"year_month":"2026-05","word_count":118,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Jaed Mosharraf","author_nicename":"jaedm97","author_url":"https:\/\/jaedpro.com\/wp-react-panel\/author\/jaedm97\/"},"doc_category_info":[{"term_name":"Field Types","term_url":"https:\/\/jaedpro.com\/wp-react-panel\/docs-category\/field-types\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/docs\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":3,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/docs\/81\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/docs\/81\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/doc_category?post=81"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/jaedpro.com\/wp-react-panel\/wp-json\/wp\/v2\/doc_tag?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}