-
Notifications
You must be signed in to change notification settings - Fork 26
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
civicrm_state field not catching cf.form.init trigger #178
Comments
@rbaugh, I'm having the same issue but I'm new to this plugin so a bit lost. Where (what file, etc.) should I add your code? |
@rgilman The file I edited was below: The two lines I adjusted were lines 33 & 88. In the code above you will see the two lines I commented out at the beginning and end and then the two lines I added in as a replacement. Line 33
Line 88
|
Got it. Thanks! |
Describe the bug
I used the "CiviCRM Contact and Address" form template to create a quick test form. When loading up the form on the CF preview option or added as shortcode to a blank page, the cf.form.init trigger doesn't ever seem to kick in. I added an alert script to the
$( document ).on( 'cf.form.init cf.add', function( e, data ) {
script and could not get it to fire. I then changed the code around slightly to remove thejQuery(document).ready( function( $ ) {
wrapper and this seems to allow the code to execute.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expect the state field to refresh itself and use the default value from the country field to filter out the list of states to selected country.
I adjusted the code on the state field and this below is working.
Other Note
When I initially tested this, it was on a fairly clean install of WP and CiviCRM. I was using the TwentyTwenty theme and when testing the form, it was initially erroring out on this code stating jQuery wasn't defined. So I switched over to a theme we are working on which I forced jQuery to load in the head and this fixed the issue.
Seems that the code could be setup and instead of just echoing inside the form, it could be added with
wp_add_inline_script( Caldera_Forms_Render_Assets::field_script_to_localize_slug(), $script_template );
which would add it in the footer with the rest of the CF scripts and makes sure that jQuery is loaded on the page.The text was updated successfully, but these errors were encountered: