Smart Grid-Layout Design for Contact Form 7

Description

The plugin uses the smart-grid css plugin to build beautiful form layouts. It introduces a graphical editor to design your forms, as well as a coloured html syntax editor built using the excellent CodeMirror editor. It is now possible to design smart layouts with ease.

In addition the plugin also introduces multiple smart input functionalities, such as,

  • tabled input sections: these allows you to group several input fields as table rows, the plugin will automatically add an ‘Add Row’ button to your front end form, giving your users the ability to add multiple rows of your grouped fields.
  • tabbed sections: with this plugin you can build tabbed sections of fields, allowing your users to add additional tabs. It is a similar concept to the tabled input section above, but in a tabbed layout insead.
  • collapsible sections: for long and complex forms you can now group your front-end fields into collapsible sections, making it easier for user to see the big picture.
  • toggled collapsible sections for optional sections. A toggle with a default Yes/No value is inserted, allowing your users to submit optional fields which within the section can be set to required in your design (See FAQ section for more info).
  • reusable sub-forms: if you have fields which repeat across multiple forms, you can now build a sub-form which you can include in your form, saving you the trouble of redesigning the form each time, but also making large forms much easier to maintain.
  • form categories: the plugin introduces form taxonomy to classify your forms for the use of online registration where users may need to be associated with a given set of forms to access.
  • dynamic dropdown fields: these are special select fields which you can populate with either existing post titles, or managed lists such as units, or even using a custom filter. This makes dynamic interlinking of existing CMS data in your dashboard a piece of cake, giving you a very powerful tool for data capture.
  • plays nice with Post My CF7 Form plugin: and best of all you can map all your forms to custom posts using the now stable Post My CF7 Form plugin.
  • redesign the form editor: this plugin now uses the WordPress default post editor page to edit/build forms, therefore making it easier for developer to plugin their functionality on top, while preserving all the hooks of Contact Form 7.

Looking for Collaborators
Are you a WordPress developer or an HTML/Javascript master? Want to collaborate on this plugin? There are some really great pieces of functionality that are in the roadmap for this plugin, but I just don’t have the time or resources to get them all on file in a timely manner. So join me on GitHub if you want to collaborate.

Checkout our other CF7 plugin extensions

  • CF7 Polylang Module – this plugin allows you to create forms in different languages for a multi-language website. The plugin requires the Polylang plugin to be installed in order to manage translations.

  • CF7 Multi-slide Module – this plugin allows you to build a multi-step form using a slider. Each slide has cf7 form which are linked together and submitted as a single form.

  • Post My CF7 Form – this plugin allows you to save you cf7 form to a custom post, map your fields to meta fields or taxonomy. It also allows you to pre-fill fields before your form is displayed.

  • CF7 Google Map – allows google maps to be inserted into a Contact Form 7. Unlike other plugins, this one allows map settings to be done at the form level, enabling diverse maps to be configured for each forms.

  • Smart Grid-Layout Design for CF7 – allows responsive grid layout Contact Form 7 form designs, enabling modular designs of complex forms, and rich inter-linking of your CMS data with taxonomy/posts populated dynamic dropdown fields.

Documentation

This plugin has a substantial set of FAQs and screenshots that is has a lot of information. Please go through the FAQs and screenshot captions to understand how to use the basic functionality.

The plugin has a number of hooks (filters and actions) which can be leveraged to further customise your form layouts and fields. Please refer to the Helper Metabox available in the form post editor when you create/edit a form. The helpers have commented code snippets which you can copy to and paste in your functions.php file to further understand how to use them.

Get in touch in the support forum if you some clarification.

A video will be made available in the near future to further demonstrate how to use this plugin, so what this space!

Support Open-source effort

This plugin would not have been possible without the following open-source efforts. Please consider visiting these plugins pages and making a donation to its authors to say thank you. Even small amount of beer money is always appreciated. Alternatively/additionally you can help in the maintenance or translation effort.

  • Beautify – a JQuery plugin to beautify html text, used in the text editor of this plugin.
  • CodeMirror – a remarkable JQuery text editor that allows for colour-coded highlighting among many other functionality. Used to edit form source code in text editor of this plugin.
  • CSS Smart Grid – a CSS plugin that allows for intuitive css styling of responsive grid layouts. Used for building the responsive form layouts.
  • JQuery Clipboard – copy text to the clipboard, used for helper links.
  • JQuery Nice Select – makes beautiful dropdown fields.
  • JQuery Select2 – this plugin converts dropdowns into powerful searchable dropdown fields.
  • JQuery Toggles – enables pretty toggle switches on collapsible sections.
  • PHP Query – a php class that enables traversing and manipulation of html documents using css selectors like JQuery. This is used to build the modular functionality of form designs.

Screenshots

  • This plugin replaces the CF7 post table page and post edit pages with WordPress core post edit and post pages. This means that other plugins that build on WordPress standards for custom admin dashboard functionality should now play nicely with CF7. One out-of-the-box improvement is the ability to customise the CF7 form table columns being displayed.
  • Form type taxonomy is introduced to manage forms. This is useful when designing forms that change according to the type of users and therefore leverages WP core taxonomy CMS functionality.
  • The CF7 form editor page is now replaced by the WP core post.php page for custom posts. It offers a UI grid building tool to help design grid layouts. This is done using a responsive CSS plugin, Smart grid, which divides a row into 12 equal width columns.
  • The CSS smart-grid plugin columns layout, the total width of a row including column offsets need to add-up to 12 equivalent widths. If you try to add more columns which takes the total width beyond these 12 units, you will end up with the extra columns flowing below.
  • The 'text' tab of the form designer allows you to edit the form source in a beautiful CodeMirror html editor with colour highlighted markup for both html as well as CF7 tags. This makes it a lot easier to customise your source code. Switching back to the grid mode, the plugin will attempt to identify new rows/columns, but if it fails to recognise your custom html code, it will simply leave it as is and display it a separate textarea.
  • You can add new rows with the '+' button in the row controls, delete with the 'bin' button which only appears on the 2nd row onwards. You can edit the row with the 'pencil' button. Similarly you can add columns with the '+' button on the column controls, delete with the 'bin' button (only available on the 2nd column onwards), and edit a column using the 'pencil' button.
  • Columns can be resized and offset.
  • A row can be converted into a collapsible 'accordion' style section to collapse part of your form into more manageable parts.
  • Columns can further be converted into grids, allowing for more complex layouts such as multiple rows within a column.
  • Once a column is converted into a grid, its inner rows have added capabilities. You can convert an inner-row into a tabled section of fields. Any fields which are added to this row will be cloneable into multiple rows by a user and therefore submit multiple sets of these fields.
  • Here is an example of a tabled section of a form, where the plugin automatically inserts a button for your uses to clone the row and any fields within it.
  • When a row is added below a table row, you can convert it to a table footer. This is useful if you want to add some instructions at the bottom of your table (or table footer headings). The plugin will then insert the 'Add Row' button below this row.
  • Similar to a table row, you can convert an inner-row into a cloneable tabbed section of fields. This is similar to the table concept except that users can add additional tabs which clone the entire set of fields presents in the tabbed row. Make sure you give your tab a label.
  • On the form front-end your users will be able to add new tabs.
  • A column can be converted into an entire existing cf7 form by editing the column ('pencil' button) and selecting the option 'Insert Form'. This will convert the column into a dropdown field from which you can select an existing form that you have previously designed. This makes for modular design of forms.
  • This plugin introduces dynamic dropdowns, which allow you to manage dropdown field options using various content managed in your WordPress dashboard. For example you can use taxonomy terms as options, or you can use existing post types' allowing your users to select/link existing content from your WordPress CMS managed data to their submission. The dynamic dropdown can also be programmatically populated using a hook filter with the last option 'Custom'.
  • A benchmark field is available which allows you to display warning when certain input values breach the benchmark limit. The benchmark field also emits a javascript event when the limit is breached so that custom javascript action can be executed.
  • Click on the code icon in any given column cell of the grid UI editor and it will take you to the equivalent code lines in the text editor.
  • v2.0 of the plugin introduces inline field hooks helpers. These are specific hooks which allow to filter custom aspect of the field. Not all tags have field specific hooks, so if any are defined they will show up with the icon in the control bar.

Installation

  1. Install the Contact Form 7 plugin.
  2. Unpack this plugin archive file into your wp-content/plugins folder.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Read the FAQs & Screenshot captions to understand how to use this plugin.

FAQ

Installation Instructions
  1. Install the Contact Form 7 plugin.
  2. Unpack this plugin archive file into your wp-content/plugins folder.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Read the FAQs & Screenshot captions to understand how to use this plugin.
1.How do I drag and sort columns in the grid editor ?

Columns can be rearranged within a row by simply dragging and dropping using the handled icon in the columns head. You can also drag and drop a column into another row, if the target row has sufficient space to receive the column, else a warning msg will appear. In that case, make some room in the target row and/or resize the column so as to ensure it will fit in the row.

Similarly you can re-organise your rows within a given grid. Your initial form is grid. You can convert an existing column into a grid.

2.How do I create a dynamic dropdown list ?

simply create a new dynamic dropdown field using the added tag in the list of available tags and select the type of dynamic list you want to populate with. You create a list which will appear in the Information metabox in your edit page once you save your form. It uses the taxonomy management functionality of WordPress but is not associated with any posts as such. Simply edit the list by adding new terms to your list. These will appear in your dropdown field.

Alternatively select an existing posts from your dashboard and the post titles will be used to populate the dropdown.

You also have the option to select a dynamic filter, and then the plugin will hook your functionality in your functions.php file to get your custom list.

3.How do I make nice dropdown selects?

When you create a dynamic dropdown, or a cf7 dropdown field, you add class:nice-select to your tag or ‘nice-select’ in the class text field option. The plugin will convert your dropdown into a beautiful nice-select field.

4.How do I make powerful select2 dropdowns?

When you create a dynamic dropdown, or a cf7 dropdown field, you add class:select2 to your tag or ‘select2’ in the class text field option. The plugin will convert your dropdown into a powerful and searchable JQuery Select2 field. You can also enable select custom user options (known as tagging in the plugin documentation: https://select2.org/tagging) by adding the ‘tags’ class to your cf7 tag, class:tags.

5.How do I display a pretty toggle switch on my collapsible section?

When you convert a row into a collapsible section (see Screenshot 8), you can check the toggle option which will insert 2 data attributes into your html row, with labels for the toggle switch on/off state. The default labels are ‘yes’ for on and ‘no’ for off. You can change the data-on and data-off attributes in the html text editor. Your form will display a toggle switch.

6.How do I reset a form?

Navigate to the ‘text’ editor of the form, select all the html and delete the editor content. The plugin will create 1 default row with a single column in the ‘grid’ editor from which you can design your form afresh.

7.The columns are filled with default html field wrappers, how do I change this ?

The plugin wraps each cf7 tag with the following html,

<div class="field">
   <label></label>
   [CF7-tag shortcode]
   <p class="info-tip"></p>
</div>

Furthermore, CF7 tags that are marked as required, have the following html <em>*</em> appended in the . This enables for smart looking fields.

If you want to only modify a single column, simply find the column in the ‘text’ editor and modify the html wrapper as per your requirements.

If you want to change these wrappers for all the fields, then you can use the hook filters, cf7sg_pre_cf7_field_html to change the html before the cf7 tag, cf7sg_post_cf7_field_html to change the html after the cf7 tag, and cf7sg_required_cf7_field_html to change the required field label markup.

Each filter has 2 attributes passed to the hooked function,

add_filter('cf7sg_pre_cf7_field_html', 'filter_pre_html', 10, 2);
function filter_pre_html($html, $cf7_key){
  //the $html string to change
  //the $cf7_key is a unique string key to identify your form, which you can find in your form table in the dashboard.
}
8.How can I customise my form ?

Custom scripts
The plugin will look for a javascript file js/{$cf7key}.js from the base of your theme root folder and load it on the page where your form is displayed. Create a js/ subfolder in your theme (or child theme folder), and create a file called <your-form-cf7key>.js in which you place your custom javascript code.

The $cf7key is the unique key associated with your form which you can find in the Information metabox of your form edit page.

If you wish to wp_enqueue_script a general javascript file for all your forms, you can use the hook smart_grid_register_scripts,
add_action(‘smart_grid_register_scripts’, ‘add_js_to_forms’);
function add_js_to_forms(){
wp_enqueue_script(‘my-custom-script’, ”, array(), null, true);
}
custom styling
Similarly you can create a css/ subfolder in your theme folder and create a file in it called <your-form-cf7key>.css and place your custom styling for your form. The plugin will then load this css file on the page where your form is displayed.

If you wish to wp_enqueue_styles a general css stylesheet file for all your forms, you can use the hook smart_grid_register_styles,
add_action(‘smart_grid_register_styles’, ‘add_css_to_forms’);
function add_css_to_forms(){
wp_enqueue_style(‘my-custom-style’, ”, array(), null, ‘all’);
}

9.Can I have required fields in toggled sections?

Yes, as of v1.1 of this plugin, toggled sections input fields are disabled when collapsed/unused, and therefore any fields within these sections are not submitted. So you can design fields to be required when toggled sections are used, and the fields will be validated accordingly too.

Please note that in the back-end, these fields which are listed in the form layout but are not submitted are set eventually set as null in the filtered submitted data. So if you hook a functionality post the form-submission, be aware that you also need to test submitted values for NULL as opposed to empty.

10.Can I group toggled sections so as to have either/or sections ?

Yes, with v1.1 you can the data-group attribute which by default is empty to regroup toggled sections and therefore ensure that only 1 of these grouped sections is used by a user. Edit your form in the html editor (Text tab) and fill the data-group attribute with the same value (no spaces) for each toggled section (div.container.with-toggle) you wish to re-group.

11.I am using Post My CF7 Form plugin, how are toggles status saved in the database?

When you install Post My CF7 Form plugin to map your form submissions to posts in the dashboard, this plugin will automatically save the toggle status, so that draft forms can be re-loaded as well accessing the data for later use. The status of the toggle is saved to the custom meta-field cf7sg_toggles_status,

$toggles = get_post_meta($post->ID, 'cf7sg_toggles_status', true);

this will retrieve an array with the following key=>value pairs,

<toggle-element-id>=>""<toggle-label>|Yes"

the key is the unique id of your toggle .container element. If you navigate to the element in the text editor you will notice that a random ‘id’ attribute has already been set, you can change this to something more meaningful.
The value of the array if set at the text string comprised of the toggle label (which you filled in), followed by the positive selection string (toggle open status) which is ‘Yes’ by default, and separated by the ‘|’ (pipe) character. If the toggle has not been opened, no key/value pairs will be saved in the array for that toggle.

12.How can I navigate/search the text editor?

As of v1.3 a search functionality has been introduced. Click anywhere in the text editor and press your search key combination (for example ‘Ctrl+F’ on windows/linux), you will see a search box at the top of the editor. This is useful if you want to edit a specific field, so once you have added a new cf7 field tag with the name say ‘your-email’, you can then search for it on the text editor to locate the code.

13. Can the text editor highlighting be turned off?

yes, you can use the following filters to either switch off only the shortcode highlighting, (add the following line to your functions.php file)

add_filter('cf7sg_admin_editor_mode', function($mode, $form_key){return '';}, 10, 2);

and you can also turn off highlight altogether by inserting this additional line to your functions.php file,
add_filter(‘cf7sg_admin_editor_theme’, function($theme, $form_key){return ”;}, 10, 2);

Reviews

Je ne comprends RIEN

I don’t understand. You read the FAQ you try the plugin, it’s…….
how to explain nicely…
You go to the movies to see Wolverine with Hugh Jackman, you end up watching a cartoon cinderella type, with dialogues on the merits of string theory in the composition of a cupcake.
I think what they have 7 friends who have write “It’s wonderful”.
The screenshot is not on my display. I’ve just 2 buttons. And nothing for grid or column !!!
As say Donald, it’s a fake plugin or I’ve live on Mars

Does what is needed in the heart of CF7

I was introduced to CF7 by another WordPress Developer. The heart of the idea is simple, create a contact form without having to use PHP or a lot of HTML code to form everything (especially if you want a simple contact form). I’ve read now on CF7 website, he never intended to control the looks but left it controllable by CSS. This is a blessing and a curse, as if he had, would have removed flexibility, however, CSS requires two ends and a lot more learning.

So why am I so impressed with this plugin? This plugin changes CF7 to have form and format. It doesn’t change the language, in fact, it itself is another language and functions on the same concept of CF7 in two ways: 1) a form for building and 2) click text and you can edit the language (CSS labels and DIV statements) directly. This was handy in repeating a section of code I needed to reproduce and alter variable names of.

It is far more powerful, CF7 + Smart Grid than if Contact Form 7 had incorporated these features to begin with, as CF7 is simple and requires a learning curve. Smart Grid too requires a learning curve. Learning CF7 and realizing you “want” (not need) a plugin to format out a page, makes Smart Grid a valuable add-in and still much faster than trying to format with CSS.

I found Smart Grid after creating a simple but very long contact form for a client and his insisting that it was too long and needed formatting to shorten it up.. After the few hours spent learning how this thing really works, I save certainly hours of time playing with CSS and plan on using it again and again..

cons: If you have contact forms that exist in a website, they will collapse do to the incorporated CSS with this plugin. That is easily fixed with <br> or as I had intended, replacing the form in the grid system. Second, existing contact forms WILL NOT suddenly format to the new grid system (no Borg mentality). So really wasn’t a negative.

ps. Read the Div tags, you will be amazed at the simplicity of his formatting and labels.

pss. someone wrote, dependence on another plugin as a con. It’s not dependent, it’s an enhancement to another awesome plugin.. There is a hug difference..

Awesome plugin & prompt support

This plugin is simply great. I haven’t seen any plugin which gives option to add multiple rows to user in front end.

Support is equally great.

Thanks again,

Great plugin for CF7

I was looking for a simple tool to create a contact form that would be a perfect match for my project. Thanks to this plugin I created a contact form about which I dreamed 🙂 Good job, definitely recommend!

Read all 8 reviews

Contributors & Developers

“Smart Grid-Layout Design for Contact Form 7” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

2.2.0

  • allows custom filtered dynamic dropdown options to be html string.

2.1.6

  • fix bug find form key by id

2.1.5

  • better tracking of toggled fields to fix checkbox/radio validation bug.
  • fix recaptcha field bug.

2.1.4

  • fix new form template setup for polylang managed translated forms.

2.1.3

  • delay loading of cf7 hidden fields to overcome CF7 Conditional Fields plugin bug.

2.1.2

  • bug fix click event on toggled titles.

2.1.1

  • bug fix on helper classes for dynamic dropdowns.

2.1.0

  • fix grid UI css issue.
  • added hook to deactivate plugin when cf7 plugin is deactivated.
  • improved email tag display for html mails for table and tab field values.

2.0.1

  • bug fix inline helper for multiple tags in single cell.
  • inline helper cleanup.

2.0.0

  • cleanup of helpers.
  • added dynamic dropdown field filter ‘cf7sg_dynamic_dropdown_option_attributes’.
  • added dynamic dropdown field filter ‘cf7sg_dynamic_dropdown_option_label’.
  • added dynamic inline filter helpers on grid UI cells.