stormuk / Gravity-Forms-ACF-Field

Advanced Custom Field custom field to select one or many Gravity Forms
234 stars 70 forks source link

Notice: Trying to get property of non-object #18

Open dwaqaddi opened 9 years ago

dwaqaddi commented 9 years ago

Hi Elliot,

I'm experiencing and issue with the plugin. It generates this error:

Notice: Trying to get property of non-object in /home/comonede/MesSites/travelersparking.com/wp-content/themes/travellers/inc/partials/gravity_form_code.php on line 4

Notice: Trying to get property of non-object in /home/comonede/MesSites/travelersparking.com/wp-content/themes/travellers/inc/partials/gravity_form_code.php on line 5

Oops! We could not locate your form.

"gravity_form_code.php" contains the code below:

<div>
    <?php 
        $form = get_sub_field('custom_form_gravity');
        gravity_form_enqueue_scripts($form->id, true);
        gravity_form($form->id, true, true, true, '', true, 1); 
    ?>
</div>

When i try to var_dump($form). it only returns:

string(3331) ""

Im using the acf gravity form plugin inside "acf flexible content". Acf version is 4.4.0 and Gravity is 1.9.

Thanks, Darwin

bhargavy commented 9 years ago

I'M getting the Same error.

Marcoevich commented 9 years ago

This should now be fixed. Can you please try with the latest version of this plugin?

Thanks!

tiborp commented 9 years ago

I am having the same notices with the latest version of the plugin, GF version 1.9.8 and ACF 5.2.5

var_dump($form) returns:

array(1) { [0]=> array(40) { ["title"]=> string(7) "Contact" ....etc. }

(removed biggest part of the returned array for readability)

Any ideas?

Thx!

tiborp commented 9 years ago

Update: I fixed this by using this:

<?php $form = get_sub_field('formulier'); gravity_form_enqueue_scripts($form[0]['id'], true); gravity_form($form[0]['id'], false, false, false, '', true, 1); ?> in my template.