{"id":15104,"date":"2025-09-25T07:57:01","date_gmt":"2025-09-25T07:57:01","guid":{"rendered":"https:\/\/www.kadencewp.com\/help-center\/?post_type=docs&#038;p=15104"},"modified":"2026-04-22T16:27:32","modified_gmt":"2026-04-22T16:27:32","password":"","slug":"populate-field-values-programmatically-form-adv","status":"publish","type":"docs","link":"https:\/\/www.kadencewp.com\/help-center\/docs\/kadence-blocks\/populate-field-values-programmatically-form-adv\/","title":{"rendered":"Populate Select, Checkbox, and Radio field option values programmatically in Form (Adv)"},"content":{"rendered":"\n<p>This guide explains how to programmatically populate option values for <strong>Select<\/strong>, <strong>Checkbox<\/strong>, and <strong>Radio<\/strong> fields inside the <strong><a href=\"https:\/\/www.kadencewp.com\/help-center\/docs\/kadence-blocks\/advanced-form-block\/\">Form (Adv)<\/a><\/strong> block.<\/p>\n\n\n\n<p>By default, these fields require options to be entered manually. Since <strong>Dynamic Content is not yet supported<\/strong>, you can instead use the WordPress <strong>render_block_data<\/strong> filter to inject options automatically. These options can come from <strong>arrays, WordPress posts, taxonomies, or other data sources<\/strong>.<\/p>\n\n\n\n<p>Each option must be returned as an array with two keys:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>label<\/strong> \u2192 the text displayed to users<\/li>\n\n\n\n<li><strong>value<\/strong> \u2192 the stored value when the form is submitted<\/li>\n<\/ul>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71, .wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71[data-kb-block=\"kb-adv-heading15104_f5b89b-71\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71[data-kb-block=\"kb-adv-heading15104_f5b89b-71\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading15104_f5b89b-71[data-kb-block=\"kb-adv-heading15104_f5b89b-71\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<p class=\"kt-adv-heading15104_f5b89b-71 wp-block-kadence-advancedheading has-theme-palette-8-background-color has-background\" data-kb-block=\"kb-adv-heading15104_f5b89b-71\">Want to see this functionality built-in without the need of custom code? Then, consider <a href=\"https:\/\/feedback.kadencewp.com\/p\/adv-form-select-dynamic-options\" target=\"_blank\" rel=\"noreferrer noopener\">voting on this Feature Request<\/a> to show your support. We often implement popular requests into our products.<\/p>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30, .wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30[data-kb-block=\"kb-adv-heading15104_8abd55-30\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30[data-kb-block=\"kb-adv-heading15104_8abd55-30\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading15104_8abd55-30[data-kb-block=\"kb-adv-heading15104_8abd55-30\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading15104_8abd55-30 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading15104_8abd55-30\">Example 1: Static Options (Array)<\/h2>\n\n\n\n<p>Use this approach when you want a predefined set of options, such as countries, departments, or product categories.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter('render_block_data', function ($parsed_block, $block, $parent_block ) {\n    $inputName = $block['attrs']['inputName'];\n\n    \/\/ Match your Field Name\n    if ('my-dynamic-field' === $inputName ) {\n        $parsed_block['attrs']['options'] = get_dynamic_options();\n    }\n\n    return $parsed_block;\n}, 20, 3);\n\nfunction get_dynamic_options(): array {\n    $items = [\n        'Option 1',\n        'Option 2',\n        'Option 3',\n    ];\n\n    return array_map(function ($item) {\n        return [\n            'value' =&gt; $item,\n            'label' =&gt; $item,\n        ];\n    }, $items);\n}<\/code><\/pre>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25, .wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25[data-kb-block=\"kb-adv-heading15104_457898-25\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25 mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25[data-kb-block=\"kb-adv-heading15104_457898-25\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25 img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading15104_457898-25[data-kb-block=\"kb-adv-heading15104_457898-25\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h3 class=\"kt-adv-heading15104_457898-25 wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading15104_457898-25\"><strong>Usage<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>In your <strong>Form (Adv) block<\/strong>, select the field.<\/li>\n\n\n\n<li>Go to <strong>Advanced &gt; Extra Settings &gt; Field Name<\/strong>.<\/li>\n\n\n\n<li>Enter <strong>my-dynamic-field<\/strong> (<a href=\"https:\/\/www.kadencewp.com\/help-center\/wp-content\/uploads\/sites\/14\/2025\/09\/Edit-Page-Test1234-\u2039-Bonn-Joel-\u2014-WordPress-2025-09-25-at-3.55.08-PM-373x1024.jpg\">view screenshot<\/a>)<\/li>\n<\/ol>\n\n\n<style>.wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f, .wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f[data-kb-block=\"kb-adv-heading15104_fccf06-6f\"]{font-style:normal;}.wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f mark.kt-highlight, .wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f[data-kb-block=\"kb-adv-heading15104_fccf06-6f\"] mark.kt-highlight{font-style:normal;color:#f76a0c;-webkit-box-decoration-break:clone;box-decoration-break:clone;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}.wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f img.kb-inline-image, .wp-block-kadence-advancedheading.kt-adv-heading15104_fccf06-6f[data-kb-block=\"kb-adv-heading15104_fccf06-6f\"] img.kb-inline-image{width:150px;vertical-align:baseline;}<\/style>\n<h2 class=\"kt-adv-heading15104_fccf06-6f wp-block-kadence-advancedheading\" data-kb-block=\"kb-adv-heading15104_fccf06-6f\">Example 2: Dynamic Options from Posts (Using WP_Query)<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_filter('render_block_data', function ($parsed_block, $block, $parent_block ) {\n    $input_name = $block['attrs']['inputName'];\n\n    if ( isset( $input_name ) &amp;&amp; 'post-dropdown' === $input_name ) {\n        $parsed_block['attrs']['options'] = get_dynamic_post_options();\n    }\n\n    return $parsed_block;\n}, 20, 3);\n\nfunction get_dynamic_post_options(): array {\n    $options = [];\n\n    $query = new WP_Query([\n        'post_type'      =&gt; 'post',    \/\/ Change to custom post type if needed\n        'posts_per_page' =&gt; 10,        \/\/ Adjust limit\n        'post_status'    =&gt; 'publish',\n        'orderby'        =&gt; 'date',\n        'order'          =&gt; 'DESC',\n    ]);\n\n    if ($query-&gt;have_posts()) {\n        foreach ($query-&gt;posts as $post) {\n            $options[] = [\n                'value' =&gt; (string) $post-&gt;ID, \/\/ Stored on form submission\n                'label' =&gt; $post-&gt;post_title,  \/\/ Shown in dropdown\n            ];\n        }\n    }\n\n    wp_reset_postdata();\n\n    return $options;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Usage<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>In your Form block, select the field.<\/li>\n\n\n\n<li>In <strong>Advanced &gt; Extra Settings &gt; Field Name<\/strong>, enter: <strong>post-dropdown<\/strong><\/li>\n\n\n\n<li>The field will now display the latest 10 posts as selectable options.<\/li>\n<\/ol>\n\n\n\n<p>With these approaches, you can programmatically populate <strong>Select<\/strong>, <strong>Checkbox<\/strong>, and <strong>Radio<\/strong> fields in Form (Advanced), pulling from either static data or dynamic WordPress content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide explains how to programmatically populate option values for Select, Checkbox, and Radio fields inside the Form (Adv) block. By default, these fields require options to be entered manually. Since Dynamic Content is not yet supported, you can instead use the WordPress render_block_data filter to inject options automatically. These options can come from arrays,&#8230;<\/p>\n","protected":false},"author":116562,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"doc_category":[420],"doc_tag":[],"knowledge_base":[7],"class_list":["post-15104","docs","type-docs","status-publish","hentry","doc_category-blocks-advanced","knowledge_base-kadence-blocks"],"year_month":"2026-04","word_count":393,"total_views":"1128","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"display_name":"Bonn","author_link":"https:\/\/www.kadencewp.com\/help-center\/author\/bonnjoelelimanco\/"},"doc_category_info":[{"term_name":"Advanced","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-blocks\/blocks-advanced\/"}],"doc_tag_info":[],"knowledge_base_info":[{"term_name":"Kadence Blocks","term_url":"https:\/\/www.kadencewp.com\/help-center\/knowledge-base\/kadence-blocks\/","term_slug":"kadence-blocks"}],"knowledge_base_slug":["kadence-blocks"],"taxonomy_info":{"doc_category":[{"value":420,"label":"Advanced"}],"knowledge_base":[{"value":7,"label":"Kadence Blocks"}]},"featured_image_src_large":false,"comment_info":0,"_links":{"self":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/15104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/users\/116562"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/comments?post=15104"}],"version-history":[{"count":3,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/15104\/revisions"}],"predecessor-version":[{"id":15110,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/docs\/15104\/revisions\/15110"}],"wp:attachment":[{"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/media?parent=15104"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_category?post=15104"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/doc_tag?post=15104"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/www.kadencewp.com\/help-center\/wp-json\/wp\/v2\/knowledge_base?post=15104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}