• Update: use <label> elements for the text labels of checkboxes and radio buttons, so users can click these to activate the checkbox.

    This patch is for the latest release of wp-contact-form-7.php (version contact-form-7.1.9.4.zip)

    Please update the distribution as well, thanks!

    --- wp-contact-form-7.php	2009-03-23 14:20:45.000000000 +0100
    +++ wp-contact-form-7.php.PATHCED	2009-03-22 10:08:02.000000000 +0100
    @@ -1346,11 +1346,11 @@
                                 ! $multiple && $_POST[$name] == $value))
                             $checked = ' checked="checked"';
                         if (preg_grep('%^label[_-]?first$%', $options)) { // put label first, input last
    -                        $item = '<label class="wpcf7-list-item-label" for="' . "$name-$key" . '">' . $value . '</label>&nbsp;';
    -                        $item .= '<input type="' . $input_type . '" id="' . "$name-$key" . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . attribute_escape($value) . '"' . $checked . $onclick . ' />';
    +                        $item = '<span class="wpcf7-list-item-label">' . $value . '</span>&nbsp;';
    +                        $item .= '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . attribute_escape($value) . '"' . $checked . $onclick . ' />';
                         } else {
    -                        $item = '<input type="' . $input_type . '" id="' . "$name-$key" . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . attribute_escape($value) . '"' . $checked . $onclick . ' />';
    -                        $item .= '&nbsp;<label class="wpcf7-list-item-label" for="' . "$name-$key" . '">' . $value . '</label>';
    +                        $item = '<input type="' . $input_type . '" name="' . $name . ($multiple ? '[]' : '') . '" value="' . attribute_escape($value) . '"' . $checked . $onclick . ' />';
    +                        $item .= '&nbsp;<span class="wpcf7-list-item-label">' . $value . '</span>';
                         }
                         $item = '<span class="wpcf7-list-item">' . $item . '</span>';
                         $html .= $item;
Viewing 3 replies - 1 through 3 (of 3 total)
  • jsixpack, at first, thank you for your good suggestion. But in my opinion, it would be better if the plugin doesn’t set id for each items. I mean, it can cause duplication of same id. In addition, from my experiences to support inexperienced newbie users, using labels can be confusable for them. It often make their HTML structure invalid. I wish to use labels, too, though. Thanks anyway!

    Not using labels in the forms is a real problem in my view.

    Using labels helps to make the contact forms properly accessible to all types of user, including blind people who may be using a screen reader, for example.

    I really like your plugin because it seems simple and well designed. However, I find that I just can’t use it because I’m not willing to use forms without proper labels on a public website. So I will have to use another contact form plugin like CFormsII instead.

    thesheep, you can use labels with Contact Form 7, of course. My reply to jsixpack meant that just it doesn’t set id for using labels. It doesn’t mean no label supported.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Contact Form 7] Use labels for checkboxes and radio buttons (patch included)’ is closed to new replies.