I'm using this module, and I've decided that I only want to allow 1 group in the entityform, so I set Group Audience field's (og_entityform_group_ref) cardinality to 1.

Using this configuration, I got the following error:
PHP Fatal error: Call to undefined method EntityValueWrapper::getIdentifier() in og_entityform.module on line 463

Comments

Zekvyrin created an issue. See original summary.

zekvyrin’s picture

Status: Active » Needs review
StatusFileSize
new65 bytes
new65 bytes

So, I've made some changes in this function and I think it's now working in all cases.

The problem is that $all_groups isn't always an array.
When cardinality is set to 1, $all_groups is an object (it is the group). When it is set to 2 or higher (or unlimited) it is an array of objects.
This is entity_metadata_wrapper's behaviour.

So what I did is:
1) check if $all_groups an array (cardinality >1) and then (if it is) check if the array is empty.

If it is an array and it is empty, it means that we have a cardinality >1 and 0 values in the field.
If it is an array and isn't empty do what we were doing before.

2) check if $all_groups is an object (cardinality is 1)
if it is, it means that we the cardinality is 1 and the field has value so we add the group properly in the array.

3) Finally, if the variable is empty (both is_array and is_object returns false), then the cardinality is 1, but the field is empty (no group), so we aren't doing anything. ( no code needed for this one)

zekvyrin’s picture

StatusFileSize
new878 bytes

Sorry, wrong patch.. please ignore my previous patches

b_man’s picture

  • zengenuity committed e534450 on 7.x-1.x authored by Zekvyrin
    Issue #2596541 by Zekvyrin: PHP Fatar error if Group audience's...
zengenuity’s picture

Status: Needs review » Fixed

Thanks @Zekvyrin. I was able to replicate the issue, and your patch fixes it. Committed.

Status: Fixed » Closed (fixed)

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