mecachisenros / cf-civicrm

Caldera Forms CiviCRM Integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connected Forms Issue

rbaugh opened this issue · comments

Describe the bug
Getting a JS error when trying to create a connected forms form. Seems this plugin is causing an issue when trying to execute some JS.

To Reproduce
Steps to reproduce the behavior:

  1. Add the Connected Forms add-on for CF
  2. Add a new form using the Connected Forms template
  3. Without any other changes, try and save the form.

Expected behavior
I expected to be able to submit the form, but the JS error is blocking this

Desktop (please complete the following information):

  • Chrome
  • Version 85.0.4183.121 (Official Build) (64-bit)

Additional context
It seems the admin.js file is trying to access a fields property of the form config json, but when using the connected forms, this fields property is not a list of form fields since this is connecting forms. You can see the json of the form config attached. I assume this is likely from the CiviCRM tab to do the price sets, so not sure if there should be some check to see if the form is a connected form and if so, don't inject the admin.js file or maybe add additional checks to make sure we don't attempt to use the fields[field_id].config if there isn't a config property.
https://github.com/mecachisenros/cf-civicrm/blob/master/assets/js/admin.js#L117

empty_form_config.txt

I ended up adding this just inside the for loop to check if the field was an object and contained the config property. Assume you could use the hasOwnProperty instead of the in check for the second conditional.

if ( !(typeof form.config.fields[field_id] === "object" ) || !( 'config' in form.config.fields[field_id] ) ) break;