Can Formidable Forms save form data to custom tables in the WordPress database, with each form field stored as a separate column

By: Ra Vista | Asked: 02/05/2023
ForumsCategory: General questionsCan Formidable Forms save form data to custom tables in the WordPress database, with each form field stored as a separate column
Ra Vista asked 1 year ago
Hi, I would like to build a web app in WordPress, with multiple tables and I would like to know:
  • Can Formidable Forms save form data to custom tables in the WordPress database, with each form field stored as a separate column?
  • Can Formidable Forms use data for combo boxes from tables in the database? For instance, when the user types a country name, could it retrieve the data from a 'country' table?
Many thanks in advance, Ra
1 Answers
Victor Font answered 1 year ago
Yes. This is done regularly for audit trails and operational data stores for reporting. You have to create the table manually and add/update the row with the global $wpdb object in frm_after_create_entry and frm_after_update_entry hooks. You'll get your data from the PHP $_POST associative array.
Victor Font replied 1 year ago

I missed the second part about lookup tables. Lookup tables are used all the time. Formidable has two types of lookup fields, Dynamic and Lookup. They are both capable of populating different field types, not just dropdowns. There's a big difference in their usage though, and it's important to understand before you start building your web app. Dynamic fields are especially useful for reporting and displaying data.

Dynamic fields link the value(s) selected in your form's lookup fields back to the entry id(s) of the row(s) in the lookup table that holds the selected value(s). This is especially useful for exposing other content in the lookup table row when creating your views. All you do is change the shortcode parameter to tell Formidable which lookup field to show. There's a lot of value in dynamic fields. This is my default choice when building applications because of the flexibility they offer.

Lookup fields store the actual text value of the lookup field in your form's input field. They store data like the standard hand built dropdown field, except the source is from a lookup table.

If this is your first experiencing building a web application, let me suggest a few Formidable Knowledgebase articles:

https://formidableforms.com/knowledgebase/dynamic-vs-lookup-fields/
https://formidableforms.com/knowledgebase/database-schema/
https://formidableforms.com/knowledgebase/applications/
https://formidableforms.com/knowledgebase/formidable-hooks/

As a developer, I think you should show particular interest in the database schema if you are not familiar with the WordPress metadata design. Formidable follows the WordPress database model. All entry data, regardless of how you recognize it as a collection of datasets, is stored in two tables.

When we say "lookup tables" in a Formidable context, you have to think of it as a data collection, not a physical database table as it would be in a normalized schema. Years ago I did a Formidable for a major Northwest University. There was a requirement to meet US Dept. of Education reporting compliance. This required an audit trail of every single change made to a Formidable system for its usage life.

Meeting this requirement means using Formidable hooks to trigger WordPress functions in the global $wpdb object and keep tables maintain for the life of the system. I had to build functions to add new fields to flat tables if someone added a field to one of the audited Formidable forms.

The bottom line is that you can use Formidable forms to trigger hooks in your webapp to do anything WordPress or PHP can do. WordPress is a powerful foundation, even for connecting to foreign databases. By "foreign database" I mean any database not native to a WordPress environment.

Good luck with your webapp! If you intend to sell it at any point, please come check out https://formidable-masterminds.com/. I'm hoping to get our developer store front up and running soon and I've got some good WordPress business development content imminently arriving called the "WordPress Database Modernization Blueprint". The tutorial and process video are free for all WordPress developers world-wide. The marketing strategy and artifacts are paid content. It will also be released as Developers Corner content on Formidable Masterminds. Developers Corner content is free to registered developers.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right