The "Primary" and "Secondary" fields are a bad concept, and it's reflected in the amount of code needed for it.

Work is undergoing in branch 1730678 to replace it with a "complex" widget.

Node edit:
Edit Post test | Site-Install.jpg

Field settings -- Remove all the confusing config, in favor of just selecting the widget types:
Groups audience | Site-Install.jpg

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Issue summary: View changes

Updated issue summary.

amitaibu’s picture

Anyone around to help me with upgrading the tests? :)

JohnnyX’s picture

Is it available in latest dev?

amitaibu’s picture

Work is undergoing in branch 1730678

JohnnyX’s picture

I tested another way to build a nice widget to set content to one or more groups....
Autocomplete Deluxe module! Works fine! Also with tag style! So groups can added and removed a nice way to content.

What is missing is a widget to add other users a simple and nice way to one or more (own) groups ;)

JohnnyX’s picture

Issue summary: View changes

Updated issue summary.

azinck’s picture

Is this just waiting on your patch being committed to ctools, or are there still specific problems with the new widget that need work?

Thanks for this. It's very exciting; should make things much better!

amitaibu’s picture

Patch for make file

jhedstrom’s picture

Testing out the patch in #6, one bit of feedback is that this is still confusing for administrators when there is an entityreference prepopulate widget in play, since this fails to populate the new widget if the administer is not part of the group.

jhedstrom’s picture

Also, unless I've misconfigured my widget, I'm getting ajax errors due to this code in og_entityreference_autocomplete_callback() always returning access denied (throwing a browser error since this isn't returned as json) for groups the administrator is not a member of.

  if ($entity_id !== 'NULL') {
    $entity = entity_load_single($entity_type, $entity_id);
    if (!$entity || !entity_access('view', $entity_type, $entity)) {
      return MENU_ACCESS_DENIED;
    }
  }
amitaibu’s picture

since this fails to populate the new widget if the administer is not part of the group

I'm getting ajax errors due to this code

I believe you, but I can't reproduce. It's seems to work fine with ER_prepopulate.

amitaibu’s picture

Oh, I understand now what you mean about #8, I'll look into it.

amitaibu’s picture

Actually I don't, re-checked, and works ok ;)

amitaibu’s picture

Status: Needs work » Needs review
FileSize
69.45 KB

And here's the patch for testbot.

btw, no longer depends on #1707810: Allow mockup field settings in ctools_field_invoke_field()

amitaibu’s picture

Issue summary: View changes

Updated issue summary.

amitaibu’s picture

Status: Needs review » Fixed

and ... committed!

jhedstrom’s picture

Status: Fixed » Needs review

When trying to edit *any* og content, an exception is thrown since $other_groups_ids is always false, thus $valid_ids is always empty.

          // Keep only the hidden group IDs on the entity, so they won't
          // appear again on the "admin" field, for example on an autocomplete
          // widget type.
          $valid_ids = $other_groups_ids ? entityreference_get_selection_handler($field, $mocked_instance, $entity_type, $dummy_entity)->validateReferencableEntities($other_groups_ids) : array();
          $valid_ids = $field['cardinality'] == 1 ? reset($valid_ids) : $valid_ids;
          $wrapper->{$field_name}->set($valid_ids);
jhedstrom’s picture

FileSize
5.45 KB

Also, if I comment out the call to the set() method from #14 to bypass the unhandled exception, when editing, both the 'Default' and the 'Administrator' values are filled in:

Selection_056.png

resulting in this error when saving:

FIELDNAME: this field cannot hold more than 1 values.

This also happens on node creation when using the entityreference prepopulate widget as an administrator.

amitaibu’s picture

Status: Needs review » Fixed

@jhedstrom,
Can you please open a new issue for this, but just to answer

> an exception is thrown since $other_groups_ids is always false

That's not right, if I'm a a user that doesn't belong to *all* groups, then $other_group_ids is populated.

azinck’s picture

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.