Skip to content
Home ยป Documentation ยป Contact Form 7 – Dynamic Text Extension ยป Form Tags ยป Dynamic Radio Buttons

Dynamic Radio Buttons

Dynamic Radio is a form tag added by Contact Form 7 – Dynamic Text Extension (DTX) that creates a group of <input type="radio"> form fields for forms created with Contact Form 7. It expands upon Contact Form 7’s radio form tag, accepting all of the options it does, along with these additional options introduced by DTX:

OptionDescriptionExample
Dynamic optionsSet a dynamic options for the radio buttons. The value(s) are shown in the form tag between quotes. It can be static text or a shortcode. If static text, use one option per line (each option is shown in the form tag between quotes, in order). Can define static options as just the option or as key/value pairs using pipes ({option value} | {option label}).

If shortcode, it must return a JSON string of key/value pairs. Alternatively, it must return valid radio button HTML that can override the other options regarding which radio button is checked or by default.

You can use a combination of static values and shortcodes, both as individual options or to return the value or label of an option.
[dynamic_radio inputname "Hello world" "Foo" "Bar"]

[dynamic_radio inputname "hello-world | Hello world" "foo | Foo" "bar | Bar"]

[dynamic_radio inputname "custom_shortcode"]

[dynamic_radio inputname "Static Foo" "shortcode_bar"]

[dynamic_radio inputname "shortcode_value | Static Label" "static value | shortcode_label"]
Selected DefaultOptionally define the radio button that is checked by default. If options use key/value pairs, only define the key here. Can be static text or a shortcode.

If using static text with spaces or special characters, or using a shortcode with parameters, the value of the default attribute should be encoded like the dynamic placeholder.
[dynamic_radio inputname default:Foo "Hello world" "Foo" "Bar"]

[dynamic_radio inputname default:foo "hello-world | Hello world" "foo | Foo" "bar | Bar"]

[dynamic_radio inputname default:CF7_GET%20key%3D%26%2339%3Bfoo%26%2339%3B "custom_shortcode"]

This last example uses CF7_GET key=’foo’ to define the radio button that should be checked on page load
ReverseBy default, the radio button comes first followed by it’s label text. By adding the label_first option, you can reverse them so the label text comes first followed by the radio button.[dynamic_radio inputname label_first]
LabelWrap each radio button and it’s label text with a <label> element.[dynamic_radio inputname use_label_element]
Id attributeSets the id attribute of the wrapper element.[dynamic_radio inputname id:foo]
Class attributeAdds to the class attribute of the wrapper element. To set two or more classes, you can use multiple class: option.[dynamic_radio inputname class:bar]

[dynamic_radio inputname class:hello class:world]
Read only attributeSets the readonly attribute to the input elements to prevent users from editing them.[dynamic_radio inputname readonly]
Cache CompatibleEnable cache compatibility mode for this field[dynamic_radio inputname dtx_pageload]
Options for the Dynamic Radio field for Contact Form 7 provided by DTX.

These settings are easily configurable using the form-tag generator.

The form tag generator screen for the dynamic radio buttons form tag

The dynamic_radio form tag was introduced in version 4.0.0 of the Contact Form 7 โ€“ Dynamic Text Extension WordPress plugin.

Related Post Module Attributes Before

array(29) {
  ["post_type"]=>
  string(4) "post"
  ["post_id"]=>
  string(1) "0"
  ["exclude"]=>
  string(1) "0"
  ["title"]=>
  string(32) "Related Articles & Tutorials"
  ["description"]=>
  string(0) ""
  ["max"]=>
  string(1) "3"
  ["post_ids"]=>
  string(0) ""
  ["exclude_ids"]=>
  string(0) ""
  ["is_series"]=>
  string(0) ""
  ["featured_term"]=>
  string(3) "307"
  ["exclude_terms"]=>
  string(0) ""
  ["exclusive"]=>
  string(1) "1"
  ["order"]=>
  string(4) "DESC"
  ["show_image"]=>
  string(2) "on"
  ["image_size"]=>
  string(6) "medium"
  ["menu_order_label"]=>
  string(0) ""
  ["show_order_label"]=>
  string(2) "on"
  ["show_date"]=>
  string(2) "on"
  ["show_meta_keys"]=>
  string(2) "on"
  ["show_modified"]=>
  string(0) ""
  ["show_author"]=>
  string(0) ""
  ["show_categories"]=>
  string(0) ""
  ["show_primary_category"]=>
  string(0) ""
  ["show_description"]=>
  string(0) ""
  ["show_reading_time"]=>
  string(2) "on"
  ["show_cta"]=>
  string(2) "on"
  ["cta"]=>
  string(9) "Read more"
  ["autoplay"]=>
  string(0) ""
  ["allow_sticky"]=>
  string(0) ""
}

Related Post Module Attributes

array(29) {
  ["post_type"]=>
  string(4) "post"
  ["post_id"]=>
  string(1) "0"
  ["exclude"]=>
  string(1) "0"
  ["title"]=>
  string(32) "Related Articles & Tutorials"
  ["description"]=>
  string(0) ""
  ["max"]=>
  string(1) "3"
  ["post_ids"]=>
  string(0) ""
  ["exclude_ids"]=>
  string(0) ""
  ["is_series"]=>
  string(0) ""
  ["featured_term"]=>
  string(3) "307"
  ["exclude_terms"]=>
  string(0) ""
  ["exclusive"]=>
  string(1) "1"
  ["order"]=>
  string(4) "DESC"
  ["show_image"]=>
  string(2) "on"
  ["image_size"]=>
  string(6) "medium"
  ["menu_order_label"]=>
  string(0) ""
  ["show_order_label"]=>
  string(2) "on"
  ["show_date"]=>
  string(2) "on"
  ["show_meta_keys"]=>
  string(2) "on"
  ["show_modified"]=>
  string(0) ""
  ["show_author"]=>
  string(0) ""
  ["show_categories"]=>
  string(0) ""
  ["show_primary_category"]=>
  string(0) ""
  ["show_description"]=>
  string(0) ""
  ["show_reading_time"]=>
  string(2) "on"
  ["show_cta"]=>
  string(2) "on"
  ["cta"]=>
  string(9) "Read more"
  ["autoplay"]=>
  string(0) ""
  ["allow_sticky"]=>
  string(0) ""
}