Gravity Forms and dynamic content
-
Hello,
I want to create popups with a Gravity form inside using this guide:
https://docs.wppopupmaker.com/article/53-create-read-more-popups-for-postsFirstly, I tried to make something like this (call shortcode in shortcode), but that was bad idea (popup was clear).
echo do_shortcode("[popup id='product-". get_the_ID() ."']". [gravityform id="1" title="false" description="false"] . "[/popup]");
After that, I found a second way to call a form, but looks like this function use echo too, so my form going out of popup:
gravity_form(1, false, false, false, '', true);
So, tried to add it to buffer and replace the form function in popup called with a $output:
ob_start(); gravity_form(1, false, false, false, '', true); $output = ob_get_contents(); ob_end_clean();
And I got errors in console:
(index):565 Uncaught SyntaxError: Invalid or unexpected token (index):573 Uncaught SyntaxError: Unexpected token < (index):679 Uncaught SyntaxError: Invalid or unexpected token (index):687 Uncaught SyntaxError: Unexpected token <
When I looked at this lines – the code (javascript) from the form got tags <p> (something like this):
<p> <script type="text/javascript"></script></p> <p> (function($){</p> <p> window.gwdc = function( options ) {</p> <p> this.options = options; this.startDateInput = $( '#input_' + this.options.formId + '_' + this.options.startFieldId ); this.endDateInput = $( '#input_' + this.options.formId + '_' + this.options.endFieldId ); this.countInput = $( '#input_' + this.options.formId + '_' + this.options.countFieldId );</p>
Disabling autop (from content and excerpt doesn’t help, also when I’m echo buffer out of popup – there is no autop)
After that – I tried to create a function that will return my content (tried with buffer and without it) – all the same like without that function:
function lol() { ob_start(); gravity_form(1, false, false, false, '', true); $output = ob_get_contents(); ob_end_clean(); return $output; }
So, how can I call the form in popup maker for all posts?
- The topic ‘Gravity Forms and dynamic content’ is closed to new replies.