How do I export multi-input fields in a single column with Gravity Forms?
August 8th, 2015: Updated to work with Gravity Forms 2.0+
November 16th, 2015: Updated to work with current version of Gravity Forms.
@bamadesigner asked:
Is there a way to export lead checkbox values from @gravityforms into one column as a CSV instead of a column for each checkbox? #WordPress
— Rachel Carden (@bamadesigner) August 2, 2015
I cooked up a quick snippet (using the gform_export_fields filter) to allow you to not only export checkboxes but all multi-input fields in a single column.
What are multi-input fields? They’re fields like the Checkbox field, Name Field, Address field, Multi Select field, etc. Out of the box, Gravity Forms allows you export the individual inputs of these fields in separate column but not all of the inputs in a single column.
Use this snippet to automatically add a “top level” option that will export all inputs for this field in a single column.
How do I install this?
- Click the “Download Plugin” button at the top of this page.
- Upload the downloaded plugin zip file via your WordPress admin (full instructions).
Hello, nice to greet you, –
I come to ask for your valuable help, we have a wordpress site, where we just have a form with an element of type ‘Checkboxes’ with the name ‘Category’, with a huge amount of ‘Choices’, at the time of consulting the entries from GF entries looks very good, but when exporting the same entries – these columns are empty, and installed this plugin, the only thing I can do is to give the option of category, which did not happen before, but the column is still empty, does not bring the information.
I’m doing something wrong, is not only install this plugin ‘Gravity Forms – Export Multi-input Fields in Single Column’ but I have to do some additional configuration on my site?
Thanks in advance for the help, attentive to your comments, greetings.
Some attachments so you can see the information about it.
-. https://imgur.com/a/0b2bnhd
Hi David,
I just tested the snippet and it works as expected. What the snippet does is to make available an option during export, for all the checkbox choices, and exports all the choices into one column in the CSV file. If you’re experiencing something else, we’ll need to dig into this further on your website. If you have a Gravity Perks license, you can submit a support ticket for this so we can assist you further.
Best,
I’m running into an issue with this snippet trigger an AJAX admin php error when trying to export data from a form with credit card fields. Running latest version on PHP 8.0. Error log says: [08-May-2023 18:39:42 UTC] PHP Warning: Trying to access array offset on value of type null in /home/public_html/wp-content/plugins/gravityforms/includes/fields/class-gf-field-creditcard.php on line 604 [08-May-2023 18:39:42 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/public_html/wp-content/plugins/gravityforms/includes/fields/class-gf-field-creditcard.php:607 Stack trace:
0 /home/public_html/wp-content/plugins/gravityforms/includes/fields/class-gf-field-creditcard.php(596): GF_Field_CreditCard->maybe_upgrade_inputs()
1 /home/public_html/wp-content/plugins/gravityforms/forms_model.php(1117): GF_Field_CreditCard->post_convert_field()
2 /home/public_html/wp-content/plugins/gravityforms/export.php(1132): GFFormsModel::convert_field_objects(Array)
3 /home/public_html/wp-content/plugins/gravityforms/gravityforms.php(4525): GFExport::add_default_export_fields(Array)
4 /home/public_html/wp-includes/class-wp-hook.php(308): GFForms::select_export_form(”)
5 /home/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(”, Array)
6 /home/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
7 /home/public_html/wp-admin/admin-ajax.php(188): do_action(‘wp_ajax_rg_sele…’)
8 {main}
thrown in /home/public_html/wp-content/plugins/gravityforms/includes/fields/class-gf-field-creditcard.php on line 607
Hi Josh, when testing localy this seems to work as expected. It will require some digging on your setup to understand what could be going on. You can contact us via our support form so we can get more information about your use case if you have an Advanced or Pro license.
Do you need to also be subscribed to Gravity Wiz for this to work? Or is this a standalone plugin? I downloaded it and it still isn’t exporting correctly. Do I also need to add the code to the website, or is installing the plugin enough? Thank you!
Hi Steve,
This is a free standalone plugin. No Gravity Wiz subscription required!
After installing and activating the plugin, a new option for exporting checkbox fields is available in the entries export. Instead of selecting the individual choices in the export, only check the checkbox field’s name to export the values into a single column.
Hello! can we use the snippet as is or do we need to edit the array fields?
Hi Annabelle,
It should work as is! If you have an active Gravity Perks Advanced or Pro license, you can contact us via our support form to help you setting it up.
Best,
We had trouble with this as it was doubling up date fields, which have multiple inputs but already export as 1 column. Simple change to Line 32
https://snippi.com/s/kchtuyn
Cheers
Hi Mike,
Thanks for the feedback and for sharing the code, but unfortunately, I haven’t been able to recreate the issue. Can you please provide us with more information on the issue? How exactly is the snippet doubling up the Date fields?
Best,
Hi,
Does this snippet work with List fields? It does seem to work well with address, and checkbox fields.
Thanks Shawn
Hey David,
Do you know if this still works with the latest version of GF? I’ve tried adding the code to our child themes functions.php file, and also tried the plugin. Neither option works. Your old screenshots no longer work so I can’t see where to check for a new field etc. Could you please add screenshots to the article?
Thank you
Hi Shaun,
I just did a test and I can confirm the snippet still works. After adding the snippet to the function.php file, you should see a top-level option that similar to the screenshot here, In that screenshot, the multi-input field is a checkbox field and the checkbox field has been made available by the snippet for selection to export all the choices selected for that field in a single column.
I hope this helps.
Best,
You mentioned as examples Name and address fields. I don’t consider those multi fields that need to be exported to the same column. I want those exported to single columns for sorting and filtering purposes in my database. But I do want checkbox fields exported to a single column. From what you described above it sounds like this snippet would also lump together all of the components of the address field and all of the components of the name field. Is that correct?
Hi Charlotte, this doesn’t remove anything, it only adds a combined option. You can still target the individual fields for the Name and Address field. And you can select the combined option for the Checkbox field.
Hey David,
thanks for this. I need to export the consolidated column values with a semicolon as separator. So instead of “car, mouse, hat” I need “car; mouse; hat” in the CSV export. Any simple way to do that? I tried for hours, but I’m stuck :(
Hi David- found a peculiarity – i’m using this with the Gravity forms + custom Post types plugin and mapping a checkbox field to a taxonomy. if you do this, it works inasmuch as it exports the FIRST item but it doesn’t export subsequent items if you have selected multiple values… latest version of WP, gravity forms, and the GF+custom post types plugin, and latest version of this snippet downloaded today.
In the current form, the plugin will “prepend” the consolidated inputs. The original cells (one for each possible answer) are still included in the export. To prevent this. simply remove lines 33 and 36.
[…] tutorial (by Gravity Wiz) adds a choice for each multi-input field allowing the field to be exported as a single […]
Hi David, thanks for developing this plugin! It seems like such an odd flaw in the thinking for Gravity Forms.
I’ve installed the plugin, but there’s no change on my site to the export options or to the exported spreadsheet. Am I missing something?
Thanks, L
Hi L, can you send me a screenshot of your export screen (not the export itself) with the plugin inactive and another with the plugin active?
I’m having the same problem Courtney outlined:
“I downloaded/installed the plugin – and activated it. Now what? I don’t see any new export options, and my export looks exactly like it did before the plugin. Am I missing something?”
My Gravity forms is version 2.1.2 and wordpress is 4.7.1
Hi Janna, see my response to Courtney.
I have the same question / experience as Amy from earlier last year:
“I downloaded the plugin – and activated it. Now what? I don’t see any new export options, and my export looks exactly like it did before the plugin. Am I missing something?”
Hi Courtney, are you running the latest version of Gravity Forms? If yes, could you send me a screenshot of your export screen before and after activation?
I’d love to be able to do the opposite of this. For example, the List field exports all field columns into a single column, but I’d like to have each field column be its own exported column (like the Name field or Address field does). Any chance this is possible?
Hi Tim, possible but not without a decent bit of coding. If this is something you want to commission, we can help.
Did you manage to do it please?
Hi Laksha,
We do not have an exact solution or snippet to export each List field column as a column in the CSV generated when exporting entries. However, a solution that may work for you, will be to use this snippet to create multiple entries based on the number of List field rows. All other field data will be duplicated for each entry and this way when the entries are exported, each List field row’s data will be exported as a new row with different column for each list field column.
https://gravitywiz.com/snippet-library/gw-multiple-entries-list-field/
Best,
Hello David,
This isn’t working for me the way it should. I have the custom field name showing up for the multi-select field 4 times (once for each selectable item [4 items total]), instead of all those selections being aggregated into a single column. Any ideas?
Can you send me an export of your form?
After upgrading Gravity Forms to version 2.0.4.x, I’ve found that the all the cells for a multi-select checkbox field are appearing empty. The headers come in okay, but there are no values.
Any thoughts?
Hi Corey, just updated this snippet to address this issue. Give it a try.
This isn’t working for me either. The columns are not consolidated when I use the export tool and the field is blank when I export.
I would assume the plugin would combine the selections into a single field separated by commas, but no luck.
I am fully updated on WP core and all plugins (including Perks and Gravity Forms).
This snippet has been updated to work with Gravity Forms 2.0+. Give the updated version a try (above).
Hi David,
Does it work with the current version of GravityForms? I am running 1.9.19 and when I activate it nothing shows up. I looked at your screenshots and don’t see those options.
Thank you
Hi Adam, I’ve just tested with the latest version of Gravity Forms (2.0.2.x) and this is working for me.
Hello, David. Is it possible to go into your code and choose which multi-select questions get compiled into a single cell?
Hi Casey, this is not readily possible.
The screen capture links you put in your reply to Amy aren’t working. I installed the plug-in, but do not see any changes.
Try those links again now, they’re working for me.
I downloaded the plugin – and activated it. Now what? I don’t see any new export options, and my export looks exactly like it did before the plugin. Am I missing something?
Hi Amy, given a multi-input field (like a Checkbox field), you would see this if you attempt to export the entries without the plugin (screenshot) and you would see this with the plugin (screenshot).
Thank you very much David! Works great now :)
Awesome! Glad to hear it.
Hi David. I was referred here by Gravity Forms when I had asked them how to do this. I tried installing the snippet and the Checkbox fields are showing up on the Export Entries page, and are being exported into a single column. However, all of the cells (other than the header) for the column are empty. Any suggestions? I’ve watched the video and also tried installing the snippet directly into my functions.php file but the issue persisted. I tried exporting only the Checkbox field as well as the Checkbox field and the individual options for that field, but in both cases, all entry rows for the Checkbox field and its options are blank (all other fields display their respective data in the csv).
Your snippet is the only code in my functions.php file other than my theme’s code to enqueue the css. Is Gravity Perks required to have this snippet export the data into the respective entries in the Checkbox column? Thank you.
Hi Sean, it looks like there was a conflict introduced in the current version of Gravity Forms. I’ve updated the snippet. You can re-download above. :)
i cant get it work. Got this fatal error
Parse error: syntax error, unexpected T_FUNCTION in /home2/ccmjmco/public_html/wp-content/plugins/gw-gravity/gw-gravity-forms-export-multi-input-fields-single-colum.php on line 22
Hi Edney, try the tips in this article as a starting point: https://gravitywiz.com/documentation/snippet-troubleshooting/
Are you integrating this into Gravity Perks?
Hi Christine, if it proves to be a popular snippet, there is a good chance it will be converted to a perk. :)