felixarntz / bootstrap-for-contact-form-7

This plugin modifies the output of the popular Contact Form 7 plugin to be styled in compliance with themes using the Bootstrap CSS framework.
https://wordpress.org/plugins/bootstrap-for-contact-form-7/
GNU General Public License v2.0
24 stars 18 forks source link

radio buttons forced required since cf7 v4.9 #50

Closed 5silver closed 6 years ago

5silver commented 6 years ago

Hi Felix,

I'm using a radio box and before v4.9 I didn't much mind if a user selected one of the options or not.

With contact-form-7 v4.9 it enforces one of the radio options must be selected, that's fine and I understand why they went that way.

Would it be possible within bootstrap-for-contact-form-7 to now automatically include required '*' to any/all radio input types?

Many Thanks, Dave

5silver commented 6 years ago

note I don't know the code (at all!) but this change in CF7BS_Form_Field.php I think shows what I'm thinking (there is probably a different / better way to do this!) :)

                            $label_required = '';
                            if ( 'required' == $mode || 'radio' == $type) {
                                    $append .= ' aria-required="true" required';
                                    $label_required = ' ' . cf7bs_get_form_property( 'required_html' );
                            } elseif( 'disabled' == $mode ) {
                                    $append .= ' disabled';
                            }
gidomanders commented 6 years ago

I changed your code a little bit, because you will not be able to display disabled radio buttons with your code. I also added a check for Contact Form 7 version 4.9 or higher, because of backwards compatibility.

5silver commented 6 years ago

many thanks! keep up the great work :D