Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connected Forms Issue #182

Open
rbaugh opened this issue Oct 7, 2020 · 1 comment
Open

Connected Forms Issue #182

rbaugh opened this issue Oct 7, 2020 · 1 comment

Comments

@rbaugh
Copy link

rbaugh commented Oct 7, 2020

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

@rbaugh
Copy link
Author

rbaugh commented Oct 7, 2020

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant