I get this notices/warnings in the checkout Process and also in some views with drupal commerce installed, using Field Group in the product entity.

Notice: Trying to get property of non-object in field_group_remove_empty_form_groups() (line 936 of C:\damp\www\...\sites\all\modules\field_group\field_group.module).

Warning: array_flip() [function.array-flip]: The argument should be an array in field_group_remove_empty_form_groups() (line 936 of C:\damp\www\...\sites\all\modules\field_group\field_group.module).

Warning: Invalid argument supplied for foreach() in element_children() (line 6134 of C:\damp\www\...\includes\common.inc).

Any hint?

Comments

bradhawkins’s picture

Exact same problem for me (also using drupal commerce).

Stalski’s picture

Status: Active » Postponed (maintainer needs more info)

I don't have any problems with fieldgroup in drupal commerce.

I can see in the error it's occurring for forms. Could you explain how I can reproduce this?

sonuku’s picture

Add something to cart
Go to checkout
Click submit without filling in any details.
Produces error for me.

Multiple Warning: array_flip() expects parameter 1 to be array, null given in field_group_remove_empty_form_groups() (line 938 of [...removed...]/sites/all/modules/field_group/field_group.module).

EndEd’s picture

In my case i used field groups in the product entity and in the product display content type. I get this error in the checkout process, in some views that uses the product entity fields and even working with rules :/

mikehie’s picture

I also get this notices/warnings when filling out the profile information for new user (profile2 + geofield + geocode + openlayers modules activated). It happens when I try to switch new country field (provided by geofield module).

<?php
Notice: Trying to get property of non-object in field_group_remove_empty_form_groups() 
(line 936 of /.../site/all/modules/contrib/field_group/field_group.module).
Warning: array_flip() [function.array-flip]: The argument should be an array in field_group_remove_empty_form_groups() 
(line 936 of /.../site/all/modules/contrib/field_group/field_group.module).
?>

This warnings & notices shown 6 times for each occurrence.

restyler’s picture

Exactly same problem on registration page (profile2 + date fields there)

vasike’s picture

jason ruyle’s picture

subscribing

dqd’s picture

I sadly have to confirm the bug. Warning occurs here on every page load 30 times.

Notice: Trying to get property of non-object in field_group_remove_empty_form_groups() (line 936 of C:\damp\www\...\sites\all\modules\field_group\field_group.module).

Warning: array_flip() [function.array-flip]: The argument should be an array in field_group_remove_empty_form_groups() (line 936 of C:\damp\www\...\sites\all\modules\field_group\field_group.module).

... on fresh Drupal 7.8 with latest devs of views, ctools, token, entity, profile 2 a.s.o

Stalski’s picture

Status: Postponed (maintainer needs more info) » Needs review

This is fixed and pushed.

This fix has fixed two bugs:
- the one reported here: there was need to check empty groups as the groups did not come from fieldgroup but from the commerce client profile or something. So any module can declare a fieldset and add it to the #groups property. Fieldgroup thus thought it had to handle that one too, but it didn't. So a check there if that element comes from fieldgroup, fixed it.
- I also saw that I did not have declared any fieldgroup and I got the error, just because commerce entity had added 3 fieldsets in #groups property. So now, there is a check to see if any #fieldgroups in general are there and acted accordingly.
This is a huge performance boost because of the unneeded prerenders.

- Edit - extra information can be found in field_group.api.php

Ready for testing.

Stalski’s picture

I also would like to add for people using commerce that it makes not much sense to create fieldgroups on the product entity as it is displayed through the product display. The way commerce does things, is exposing the variant fields into the product display so they are handled as separate fields. Use fieldgroups in the product display all you want but imo not in the product entity.

If I said anything stupid here, let me know as I am trying to fully understand commerce as well.

dqd’s picture

Status: Needs review » Reviewed & tested by the community

Bug fixes work smoothly, Stalski. Messages disappeared.

Stalski’s picture

Great! Thx for the feedback. Other who can confirm this?

vasike’s picture

i still have errors with commerce.

Warning: array_flip() [function.array-flip]: The argument should be an array în field_group_remove_empty_form_groups() (linia 941 din drupal_path/sites/all/modules/contrib/field_group/field_group.module).

i have fieldgroups defined within Commerce Profiles entity, Order profile as well and for Checkout i have both Chechout panes with and without fieldset wrapper.

Is this a commerce issue?

Stalski’s picture

Status: Reviewed & tested by the community » Active

Ah, that's what I did not test yet. So in this case the commerce profile entity has field_groups.
I'll test this and get back to you.
Thx for the feedback

vasike’s picture

also for Order entity

vasike’s picture

any updates for orders and commerce profiles field groups in checkout?

vasike’s picture

solution that worked for me:

just a checking isset($group->children) before the $group_children array_flip():

    // Remove empty elements from the #groups.
    if (empty($element) && isset($form_groups[$name]) && !is_array($form_groups[$name])) {
      foreach ($form_groups as $group_name => $group) {
        // HERE
        if (isset($group->children)) {
          $group_children = array_flip($group->children);
          if (isset($group_children[$name])) {
            unset($form_groups[$group_name]->children[$group_children[$name]]);
          }
        }
      }
    }
vasike’s picture

Status: Active » Needs review
Stalski’s picture

Status: Needs review » Fixed

Thx. Fixed and pushed to git.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Forgot that one and could be usefull to see whats happening