Title: Default value in dynamically generated select field?
Last modified: March 17, 2021

---

# Default value in dynamically generated select field?

 *  Resolved [torkeller](https://wordpress.org/support/users/torkeller/)
 * (@torkeller)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/default-value-in-dynamically-generated-select-field/)
 * I have a CF7 form with a select field for the recipient. With “default: get” 
   i can select a line in the dropdown from a parameter in the calling URL.
    So 
   far so good. But now I would like to generate the drop-down list dynamically (
   via the ‘wpcf7_form_tag’ hook in functions.php). This also works. But no longer
   the default choice from the calling URL. What can I do? (And by the way: If the
   select field is a recipient field, at design time it must contain an valid address,
   else a “illegal syntax” message is trown.) [select* empfaenger include_blank 
   default:get “xyz|xyz@xyz.de”]

Viewing 1 replies (of 1 total)

 *  Thread Starter [torkeller](https://wordpress.org/support/users/torkeller/)
 * (@torkeller)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/default-value-in-dynamically-generated-select-field/#post-14213931)
 * I was able to identify the problem.
    In select.php, the the URL parameter (symbolic
   e-mail name) is compared with the e-mail addresses (array $values), not with 
   the e-mail labels (array $labels):
 * Instead of:
    ` foreach ($values as $key => $value) { if ( $hangover ) { $selected
   = in_array( $value, (array) $hangover, true ); } else { $selected = in_array(
   $value, (array) $default_choice, true ); } $item_atts = array( ‘value’ => $value,‘
   selected’ => $selected ? ‘selected’ : ”, ); I changed it to: `foreach ($labels
   as $key => $value) {`
 * Now it works as expected.
    -  This reply was modified 5 years, 2 months ago by [torkeller](https://wordpress.org/support/users/torkeller/).

Viewing 1 replies (of 1 total)

The topic ‘Default value in dynamically generated select field?’ is closed to new
replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [default value](https://wordpress.org/support/topic-tag/default-value/)
 * [dynamic select](https://wordpress.org/support/topic-tag/dynamic-select/)
 * [GET parameter](https://wordpress.org/support/topic-tag/get-parameter/)

 * 1 reply
 * 1 participant
 * Last reply from: [torkeller](https://wordpress.org/support/users/torkeller/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/default-value-in-dynamically-generated-select-field/#post-14213931)
 * Status: resolved