Wordpress 联系人表单7中的复选框选项图像
我想用这个图像作为一个选项来签入联系人表单7。我搜索并找到了用单选按钮实现的方法。我在代码中做了更改,它确实起到了复选框的作用,但在提交表单时它只发送一个值,而不是多个值 这是我正在使用的代码。请告诉我需要改变什么Wordpress 联系人表单7中的复选框选项图像,wordpress,contact-form-7,Wordpress,Contact Form 7,我想用这个图像作为一个选项来签入联系人表单7。我搜索并找到了用单选按钮实现的方法。我在代码中做了更改,它确实起到了复选框的作用,但在提交表单时它只发送一个值,而不是多个值 这是我正在使用的代码。请告诉我需要改变什么 function add_shortcode_imagecheckbox() { wpcf7_add_shortcode( 'imagecheckbox', 'imagecheckbox_handler', true ); } add_action(
function add_shortcode_imagecheckbox() {
wpcf7_add_shortcode( 'imagecheckbox', 'imagecheckbox_handler', true );
}
add_action( 'wpcf7_init', 'add_shortcode_imagecheckbox' );
function imagecheckbox_handler( $tag ){
$tag = new WPCF7_FormTag( $tag );
$atts = array(
'type' => 'checkbox',
'name' => $tag->name,
'list' => $tag->name . '-options' );
$input = sprintf(
'<input %s />',
wpcf7_format_atts( $atts ) );
$datalist = '';
$datalist .= '<div class="imgcheckbox">';
foreach ( $tag->values as $val ) {
list($checkboxvalue,$imagepath) = explode("!", $val
);
$datalist .= sprintf(
'<label><input type="checkbox" name="%s" value="%s" class="hidecheckbox" /><img src="%s"></label>', $tag->name, $checkboxvalue, $imagepath
);
}
$datalist .= '</div>';
return $datalist;
}
有点晚了,但我现在有这个问题 在输入名称中添加[]
$datalist .= sprintf(
'<label><input type="checkbox" name="%s[]" value="%s" class="hidecheckbox" /><img src="%s"></label>', $tag->name, $checkboxvalue, $imagepath
);