PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Populate a Gravity Forms form with data from a table?

  1. I am looking to create a Booking/Reservations form using Gravity Forms.

    Is it possible to populate a Gravity Form form with data from a table? I can create a table that contains bookable time slots with a field for booked (yes/no). I would envisage a two-step user input:

    1) Choose day to book. Click 'check for available time slots'

    If an available slot(s) is found:

    An sql query would be made to retrieve the data required to show the radio-buttons.

    2) Choose a time. Only available times would be displayed as a radio-button choice.

    Otherwise display: "Sorry, no time are available on this day".

    I'd also like a function for the user to click: Find first available slot.

    Is this possible? I can setup the table and populate it, I just don't know if Gravity Forms has the possibility of working like this.

    Posted 11 years ago on Sunday November 11, 2012 | Permalink
  2. This would be an advanced customized use of Gravity Forms. There are a couple things to remember.

    The gform_pre_render filter can be used to modify the fields in the form, but it runs before the form is rendered and no other time. So, you might have to use multiple forms and pass data from one form to the next, and then the next form is rendered, call the gform_pre_render filter, and based on input from the previous form, run your SQL to pre-populate the next form.

    If you want to modify a form based on a user's input in that same form, you'd have to use conditional logic (which is built in to Gravity Forms) or jQuery. You can only use conditional logic if you have a finite set of choices and know them going in. You can use jQuery to add or remove options from the form when it's being displayed.

    I suspect you could accomplish what you want, but it's a pretty advanced application which will require some work on your part. My advice is to try it and see where you get stuck and see if you run into any limitations in Gravity Forms that we can't work around.

    Posted 11 years ago on Monday November 12, 2012 | Permalink