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

Unable to do advanced field layouts #25

Closed Nimdraug closed 7 years ago

Nimdraug commented 8 years ago

Found your plugin when trying to get cf7 to play nicely with bootstrap proved too difficult and it's a great plugin which mostly covers our requirements.

The only thing that is missing tho is for us to be able to make more advanced field layouts. By this I mean we need to be able to have the form be horizontal layout in general but be able to have multiple fields for one label.

So for instance we would like to have one label that says Address and have 4 fields in there with different column widths so the form looks more compact. Another example would be a row for date of birth with 3 dropdown fields each at 4 colums.

Having had a brief look through the code I thought of 2 possible solutions.

Either you allow each field shortcode to override the overall form layout and then add another form layout called 'none' which will cause just the field to be output without any form-group wrappings. So entering: [text* first_name field_layout:none class:col-sm-6][text* last_name field_layout:none class:col-sm-6] would output just the two fields as 6 cols each alowing you to add your own wrapping markup

Or you could add a field to just turn off the wrapping markup an leave the form_layout untouched. So following the same example as above the fields defs would look something like: [text* first_name field_wrapper:false class:col-sm-6][text* last_name field_wrapper:false class:col-sm-6]

I would have attempted the changes myself and submitted a pull-request but wont have any time this year so I might give it a go after the xmas break.

felixarntz commented 8 years ago

Sounds good! I would prefer the field_wrapper approach since in my opinion it describes the issue better - also there are already some properties suffixed with -layout, and I don't wanna cause confusion.

I won't have time for the rest of this year either, it has to wait until the next release. I will definitely integrate this functionality into it myself when the time comes - however I would appreciate if you submitted a pull-request to take care of it. :)

felixarntz commented 7 years ago

Same issue: https://wordpress.org/support/topic/horizontal-form-with-multiple-elements-per-row/

felixarntz commented 7 years ago

8a64bf1a79443e51f65d7c2af4d42f7ea8824663 and dca78fec9b995a5423f0507092dd586485ee34ef in combination with each other make this possible.

The layout form setting now supports a new value 'none' that will essentially only render the field itself (no wrappers, no label, no anything else :) ).

The second of these commits allows to override any form setting parameter on a per-field basis. This will also make some other use-cases possible.