Replies: 0
Hi,
I’ve come here because I fail to set a default ‘option’ for a select input in my form. I want to make it pass by the shortcode so my writers could choose the default option depending on the subject of the article. So I tried this method : https://contactform7.com/getting-default-values-from-shortcode-attributes/
But it doesn’t work.
There is what I’ve done :
In the form edition :
[select* services default:shortcode_attr class:cf-dp-services "Wireless Alarms|A02" "Security Phone|S03" "Locks|S08" "Remote Monitoring|R08"]
In the shortcode on an article about Remote Monitoring :
[contact-form-7 id="5488" title="Article Form" services="Remote Monitoring|R08"]
The entiere functions.php of my child theme :
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'parent-style-shortcodes', get_template_directory_uri() . '/css/shortcodes.css' );
wp_enqueue_style( 'parent-style-prettyphoto', get_template_directory_uri() . '/css/prettyPhoto.css' );
wp_enqueue_style( 'parent-style-woocustom', get_template_directory_uri() . '/css/woo-custom.css' );
wp_enqueue_style( 'parent-style-responsive', get_template_directory_uri() . '/css/responsive.css' );
}
add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
$attr_se = 'services';
if ( isset( $atts[$attr_se] ) ) {
$out[$attr_se] = $atts[$attr_se];
}
return $out;
}
?>
But the forms keep the first choice (Alarms) as default option of the select input…
What did I wrong ?
Thank you in advance