• Resolved Demian

    (@demian85)


    Hi,

    I’m expecting to see the Gravity Form as a form that can be submitted, instead it returns into arrays on the frontend.

    In an ACF form which is active on a post the user can select a Gravity Form from a dropdown. In the frontend I put [acf field=”gravity_form”].

    Why is this returning into arrays instead of a working form?

    With thanks,
    Demian

    • This topic was modified 3 years, 1 month ago by Demian.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    Please read the instructions. https://github.com/DannyvanHolten/acf-gravityforms-add-on. This plugin allows the selection of one or more forms in an ACF field group. It does not provide any function for the front end of the website.

    The shortcode [acf] is not one I’m familiar with. You may need to contact the provider of this shortcode in order to build the output for your website.

    Thread Starter Demian

    (@demian85)

    Yes, I figured this out. But to me that seems a little useless, as you want to be able to put a Gravity Form into the frontend via an ACF.

    So to do this dynamically, I created the following:

    1. Create ACF Field with Gravity Forms which returns into the form’s ID.
    2. Nested the default ACF shortcode into the GF shortcode:

    function nested_shortcode_gf_acf(){
    	echo do_shortcode('[gravityform id="' . do_shortcode('[acf field="gravity_form"]"') .' title="false" description="false"]');
    }
    add_shortcode('gravity_acf','nested_shortcode_gf_acf');

    3. Add the shortcode [gravity_acf] and in the frontend it gives the Gravity Form.

    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    There are myriad uses for the Gravity Form ID and there are many technologies to output them on a website. Achieving this is outside the scope of a simple field selector plugin.

    Thread Starter Demian

    (@demian85)

    I gave a solution to my problem in my previous message, but to reply to your statement.

    The plugin gives output options:

    So these choices could be extended to output the gravity form as it is, and not limited to ID and Object.

    @demian85, thanks for that shortcode. I did modify it (changed echo to return) to make it work better for inserting within the content using the Shortcode block.

    function nested_shortcode_gravity_acf(){
    	return do_shortcode('[gravityform id="' . do_shortcode('[acf field="gravity_form"]"') .' title="false" description="true"]');
    }
    add_shortcode('gravity_acf','nested_shortcode_gravity_acf');
    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    @demian85 I can see that this could be useful on a per-project basis. However, the [acf] shortcode requires that you specify both the post ID and the custom field name (which can be different for any post type and different within infinite instances within any theme or plugin), wherever a form is to be output.

    This also has to be placed in the code (using do_shortcode) or by placing it using a shortcode block at the precise place in which the developer or editor wishes the output to appear. This therefore presents a limitless range of choices.

    As our plugin is only intended to provide a field type which can be used in an ACF form, the kind of functionality you’ve suggested is far outside its scope. The existing options “ID” or “post object” both work as intended.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Frontend returns into arrays’ is closed to new replies.