{"id":266,"date":"2022-12-14T10:06:39","date_gmt":"2022-12-14T10:06:39","guid":{"rendered":"http:\/\/localhost:8888\/?p=266"},"modified":"2025-11-26T10:06:39","modified_gmt":"2025-11-26T10:06:39","slug":"dropdown-block","status":"publish","type":"post","link":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/2022\/12\/dropdown-block\/","title":{"rendered":"Dropdown Block"},"content":{"rendered":"\n<p>The <strong>Dropdown<\/strong> block allows the user to select an item. But what is an item and how do we define it? <br>It can be created using a JSON input, and we provide two options:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>a simple array with items<\/li>\n\n\n\n<li>an array of objects that require the keys <strong><kbd>label<\/kbd><\/strong> and <strong><kbd>value<\/kbd><\/strong><\/li>\n<\/ol>\n\n\n\n<p>Below we provide two examples.<\/p>\n\n\n\n<div class=\"wp-block-inseri-core-text-editor\" data-attributes=\"{&quot;blockId&quot;:&quot;Psery8bPn8QR9NIDtbU2F&quot;,&quot;content&quot;:&quot;%5B%22item%201%22%2C%20%22item%202%22%2C%20%22item%203%22%5D&quot;,&quot;contentType&quot;:&quot;application\/json&quot;,&quot;editable&quot;:false,&quot;height&quot;:60,&quot;isVisible&quot;:true,&quot;label&quot;:&quot;JSON input as 1. a simple array with items&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;textEditor-example-1&quot;}}\">is loading &#8230;<\/div>\n\n\n\n<div class=\"wp-block-inseri-core-text-editor\" data-attributes=\"{&quot;blockId&quot;:&quot;Psery8bPn8QR9NIDtbU2Fc12&quot;,&quot;content&quot;:&quot;%5B%0A%20%20%20%20%7B%20%22label%22%3A%20%22item%201%22%2C%20%22value%22%3A%20%7B%20%22bar%22%3A%2011%2C%20%22foo%22%3A%203%20%7D%20%7D%2C%0A%20%20%20%20%7B%20%22label%22%3A%20%22item%202%22%2C%20%22value%22%3A%2042%20%7D%2C%0A%20%20%20%20%7B%20%22label%22%3A%20%22item%203%22%2C%20%22value%22%3A%20%22Foo%20bar%22%20%7D%0A%5D&quot;,&quot;contentType&quot;:&quot;application\/json&quot;,&quot;editable&quot;:false,&quot;height&quot;:133,&quot;isVisible&quot;:true,&quot;label&quot;:&quot;JSON input as 2. an array of objects that require the keys label and value&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;textEditor-example-2&quot;}}\">is loading &#8230;<\/div>\n\n\n\n<p>Edit the text block below (we can make the text editable so the user can change it) and check the dropdown updates live:<\/p>\n\n\n\n<div class=\"wp-block-inseri-core-text-editor\" data-attributes=\"{&quot;blockId&quot;:&quot;avmahR8D2OZwHz3oeiL3w&quot;,&quot;content&quot;:&quot;%5B%22a%22%2C%22b%22%2C%22c%22%5D&quot;,&quot;contentType&quot;:&quot;application\/json&quot;,&quot;editable&quot;:true,&quot;height&quot;:140,&quot;isVisible&quot;:true,&quot;label&quot;:&quot;Feel free to edit the JSON text below&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;textEditor-1&quot;}}\">is loading &#8230;<\/div>\n\n\n\n<p>Pay attention to the value that you select from the Dropdown and next at its output value which can be used as an input of another block. If the items of the JSON array are Objects, the <code><strong>label<\/strong><\/code> can be selected, and the <code><strong>value<\/strong><\/code> is its corresponding output.<\/p>\n\n\n\n<div class=\"wp-block-inseri-core-dropdown\" data-attributes=\"{&quot;blockId&quot;:&quot;ak3IbPTyEXvFtT7sKYPhf&quot;,&quot;clearable&quot;:true,&quot;inputKey&quot;:&quot;avmahR8D2OZwHz3oeiL3w\/content&quot;,&quot;label&quot;:&quot;Choose an item&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;dropdown-1&quot;},&quot;searchable&quot;:true}\">is loading &#8230;<\/div>\n\n\n\n<div class=\"wp-block-inseri-core-text-viewer\" data-attributes=\"{&quot;blockId&quot;:&quot;sbulfTYLyx8HZaCx7CAji&quot;,&quot;content&quot;:&quot;&quot;,&quot;height&quot;:150,&quot;inputKey&quot;:&quot;ak3IbPTyEXvFtT7sKYPhf\/selected&quot;,&quot;label&quot;:&quot;&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;textViewer-jO4&quot;}}\">is loading &#8230;<\/div>\n\n\n\n<p>For more details please see the corresponding <a href=\"https:\/\/inseri-swiss.github.io\/inseri-core-wp\/blocks\/dropdown\/\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:60%\"><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-inseri-core-export alignright\" data-attributes=\"{&quot;align&quot;:&quot;right&quot;,&quot;blockId&quot;:&quot;vaxQQCzmrnvQCf4meQgfk&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;export&quot;},&quot;postId&quot;:266}\">is loading &#8230;<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-inseri-core-share alignright\" data-attributes=\"{&quot;align&quot;:&quot;right&quot;,&quot;blockId&quot;:&quot;KTETwIissQyi0jL3ZpuwV&quot;,&quot;copiedText&quot;:&quot;Copied&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;share&quot;},&quot;showIcon&quot;:true,&quot;text&quot;:&quot;Share&quot;}\">is loading &#8230;<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Dropdown block allows the user to select an item. But what is an item and how do we define it? It can be created using a JSON input, and we provide two options: Below we provide two examples. Edit the text block below (we can make the text editable so the user can change [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[39,40,50,52,53],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-inseri-core-block","tag-dropdown","tag-export","tag-share","tag-text-editor","tag-text-viewer"],"_links":{"self":[{"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/comments?post=266"}],"version-history":[{"count":1,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":2109,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/posts\/266\/revisions\/2109"}],"wp:attachment":[{"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/media?parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/categories?post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zi.uzh.ch\/whp\/science-it\/inseri\/wp-json\/wp\/v2\/tags?post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}