Contact Form 7 option by default to print as selected value by mail

[select my_select class:input class:styled "Select Options"   
"Option 1" "Option 2" "Option 3" "Option 4"]

      

Question:

How can I prevent printing 'Select Options'

if the user has not selected any options when receiving email? If the user chooses the first option ('Select Options')

, he does not have to print like 'Select Options'

mail.

+3


source to share


5 answers


[select my_select first_as_label class:styled "Select Options" "Option 1" "Option 2" "Option 3" "Option 4"]



Alternatively, you can check the documentation .

+3


source


Change your select tag to

[select my_select class:input class:styled include_blank "Option 1" "Option 2" "Option 3" "Option 4"]

      

The first option will have "---" as text and empty value, <option value="">---</option>



If you want to replace the text "---" with "Select parameters", add the following code to functions.php

function my_wpcf7_form_elements($html) {
    $text = 'Select Option';
    $html = str_replace('---',  $text , $html);
    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');

      

+2


source


Here is a simple solution to add Place Holder for Drop Down Menu selection

[select* Test first_as_label "Placeholder" "Option 1" "Option 2"]

      

0


source


[select * BurjBestCompany default: get "Best Advertising and Marketing Campaign" "Best Airline"]

BurjBestCompany must match the query string name

For example:

http://example.com/?BurjBestCompany=The+Best+Advertising+%26+Marketing+Company

      

0


source


These solutions worked exactly as I wanted. so all forms have consistency and the same default selected - you need to add "include_blank" to the field shortcode:

/**
 * Customize the default option selected on CF7
 */
 function my_wpcf7_form_elements($html) {
    $text = '—';
    $html = str_replace('---',  $text , $html);
    return $html;
}
add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements');

      

As https://stackoverflow.com/users/80368/anand-shah commented

0


source







All Articles