Populating Fields from an existing SQL source

I am trying to create an ‘Amend’ record form. I am using Gravity Forms + GFWPDB AddOn

The form connects to a database table record and populates the form fields with the existing data (in the record). It gets the record ‘ID’ from the querystring on the URL

The user can change/amend the content of any field(s) and on submitting the form the database record is updated with the contents of the field(s).

Please advise whether GF Perks can do this and which perk I should look at, and if possible the documentation which indicates the method.

As far as I know there’s no Gravity Wiz Perk to replace the Gravity Forms - WPDB / MySQL Connect add-on.

But you can create your own custom code to dynamically populate a field, here’s an example tutorial: Dynamically Populating Drop Down, Radio Buttons or Multi-Select Fields - Gravity Forms

Hey Samuel - thanks for getting back to me. I dont think I expressed myself clearly.

What I am trying to do is create the ‘update/amend’ form and populate it with data from a specific record. If I can do it within the Gravity Forms environment then I can figure out how to do it withthe MySQL. My problem is that I cannot work out how to do it in the Gravity Forms environment.

Hello Samuel. I have another question.

Can I use a php snippet (which gets a value from a MySQL table) as the default value in the settings of a Gravity Form field.Can you point me in the direction of an example of this please.
Thank you

Hi Anthony,

You should be able to populate data from a MySQL Database with Populate Anything.

You could create a filter to populate a specific record based on any value stored in the DB.

This Perk allows you to populate data but it doesn’t update data on the DB.

Cheers,

Hello Dario

Thank you for your response

Populate Anything

I am using GF WPDB AddOn to update the MySQL table. So populate anything could work.

  1. Can I test populate anything in a sandbox before committing to Gravity Perks.

Gravity Forms use a ShortCode as a default.

When setting up a GF field I believe that we have the option to use a shortcode as the default value.

  1. Is that correct

  2. Can I use a php snippet to create a short code that returns the value in a MySQL table field and then insert that shortcode in (2) above.

Hope to hear from you

Best

Anthony

Anthony Silver

Co -Founder

image001.png

D: +44 (0)122 390 1260

M: +44 (0)796 877 6157

Hi Anthony,

Thanks clarifying. What you describe seems possible with Populate Anything. Depending on what you need to populate, Populate Anything has embedded capabilities to populate data based on the current user, post, or other database values.

We don’t have a sandbox, but you can try Gravity Perks Risk-Free for 30 days.

Best!

Hello Dario

Thanks again for responding promptly. I suppose my question is

By using PHP Snippets, can I create shortcodes (that holds data from MySQL) and then use them in the ‘defaults’ setting of the Gravity form

Best

Anthony

Anthony Silver

Co -Founder

image001.png

D: +44 (0)122 390 1260

M: +44 (0)796 877 6157

Hi Anthony,

It seems you should be able to that: https://docs.gravityforms.com/using-dynamic-population/#shortcode.

I hope this helps.

Best,

Anthony, the field_values parameter for the GF shortcode is only for “static” values that you type along with the shortcode parameters, you can’t use that for dynamic values from your database.

The link I posted previously shows you an example of what you need to do to populate a GF drop down field, there are examples for other field types in the following links:

If you want to update your database with any form value submitted, then you would need to create additional code fired by the gform_after_submission hook: https://docs.gravityforms.com/gform_after_submission/

To be honest if you have already your form working with the Gravity Forms - WPDB / MySQL Connect add-on add-on and you don’t have enough coding experiencing, your best bet would be to continue using this add-on or try if the Perk suggested by Dario can fit your needs.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.