Adding a new Question to the Gravity Forms
Part 1: New Question Record in FMP
Before creating a new field, you’ll need to create a new question record in FileMaker Pro. While you may need to add Question records, you will not need a separate version for each show. [When adding this question to the FMP table “Question” (Scripts > Questions Layout), make note of the Question ID, which the system adds automatically.] OR [You’ll add a question id manually when adding this question to the FMP table “Question” (Scripts > Questions Layout).] We started numbering new questions from 1001. Please keep in mind that the number should be unique.
Part 2: WP and Gravity Forms
An Indoor Show Exhibitor Application Form can be modified by an Admin User in WordPress from Admin Dashboard > Forms > Show Registration - Indoor Show - Exhibitors. Click on the form to open it. It’s drag-and-drop with all fields on the right and your form on the left. For a simple question field, choose Single Line Text from the Standard Fields and drag it to the form.
After your new field is created, go to the advanced tab of this field. You need to configure each new field so they'll reference the correct FMP Question ID when added to the Member's Order as an Order Item in FMP. Here is an example of one of the questions already added to the form. If you go to the Advanced Tab of this field, you’ll see the FMP Question ID in the “Admin Field Label” field. Please remember the Field ID (it’s 21 in the screenshot below) of your new question - you’ll need it during the next step.
Part 3: Edit functions.php file
Finally, you’ll go to Admin Dashboard > Appearance > Theme Editor. Open function.php file (step 3 on the screenshot), press Command + f to enter find mode and type in “register_ex”. This is the name of the functions where you need to add an additional block. Currently, this function starts on line 1260 but this might change later when I will be reorganizing things.
If you are adding a Text field or Dropdown
All you need to here is to copy-paste another block of code. If you scroll a little bit, you’ll see orange comments that start with “get the field ** - text of the question.” Somewhere between those blocks (right before the start of the comments for the next questions), you’ll need to add this code:
//get the field field **(your field number) - Text of your new question $field = GFFormsModel::get_field( $form, 23 ); //replace 23 with your field number $admin_label = $field->adminLabel; array_push($portalData, array( "Order_Item::label" => "OPTION", "Order_Item::created_date" => date("m,d,Y"), "Order_Item::question_id"=> $admin_label, "Order_Item::description" => rgar($entry, '23'))); //replace 23 with your field number
That’s it! If it’s just another text field and its label in FM should be “Option” you’re all done here. Press “Update File” to save it. If there is no WP error, most likely it will work as expected.
If you are adding a new Checkbox or Radio Button
For the new checkbox, the code will be a little bit different. Don’t forget to save your file.
//get the field field **(your field number) - Text of your new question $field_id = 27; // Update this number to your field id number $field = RGFormsModel::get_field( $form, $field_id ); $value = is_object( $field ) ? $field->get_value_export( $entry, $field_id, true ) : ''; $admin_label = $field->adminLabel; array_push($portalData, array( "Order_Item::label" => "OPTION", "Order_Item::created_date" => date("m,d,Y"), "Order_Item::question_id"=> $admin_label, "Order_Item::description" => $value));
Other Fields
Other fields, like product and list fields, are a little bit harder to add but I can include the detailed instructions on how to do it if needed. I would not recommend adding a list field without our help, since sending its data to FileMaker is a complicated process.
Updating the Question Text or Price in the Gravity Forms
To update the text of a question or the price of a product, go to Admin Dashboard > Forms > Show Registration - Indoor Show - Exhibitors. Click on the form to open it. It’s drag-and-drop, with all fields on the right and your form on the left. Find your question and click on the question you want to change. Whether you’re changing the text, the price, or both, simply change the values you see (reference the screenshot below). Then press the “Update” button on the right and that’s it! There is nothing else to do here, your question was successfully updated!
If you change the text of a question, go to FileMaker > Question Layout (see screenshot 1), find your question by ID (see Part 2 above, the Admin Field label is your question ID in FM) and update the text to match the revised question. This is not required but recommended since changing the text of the question will update the description that you see in the Order>Item portal but not the FileMaker question itself. Even though the WordPress and FileMaker Questions will be linked/related, the text will be different until you manually change the Question’s text on the Question Layout.