Here is what I'm using:

Drupal 7.7
field_collections v7.x-1.x-dev (downloaded last week)
field_permissions v7.x-1.0-alpha1

My symptoms:

- Fields in the collection which are restricted from edit are correctly hidden on a node form to users who don't have those fields' edit permissions
- Fields in the collection which are restricted from view are incorrectly displayed in the rendered node
- Submitting the node edit form, although restricted fields in the collection are not displayed, triggers these undefined index warnings for each restricted field:

Notice: Undefined index: #title in theme_field_collection_table_multiple_value_fields() (line 85 of /blah/blah/blah/sites/all/modules/field_collection_table/theme/

Here are relevant lines I've found in the field_permissions in my own search where this integration may be added:

line 115: function field_permissions_field_access($op, $field, $obj_type, $object, $account)
line 11: function _field_permissions_field_view_access($field_name, $field_permissions, $obj_type, $object, $account)
line 63: function _field_permissions_field_edit_access($field_name, $field_permissions, $obj_type, $object, $account)

Members fund testing for the Drupal project. Drupal Association Learn more


westbywest’s picture

The 2nd symptom described above was resolved by adding field_access awareness to field_collections_table:

RobLoach’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Try update?

adellefrank’s picture

I, too, have found that permissions for VIEWING OWN/EDITING OWN field is not working when that field is a subfield of a field collection.

To reproduce this problem, give View Own/Edit Own permissions to the authenticated user for a field collection "mycollection" and its subfield "subfield1" in a content type's "mytype". I've attached a feature with the setup I described above for testing. This feature uses:

adellefrank’s picture

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

I'm hoping I can move this back into the "needs work" category, since I provided lots more info in comment #3.

DrupalDan’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Category: feature » bug
Status: Needs work » Active

I got a similiar problem. I use the module to restrict access to files that users uploaded. I gave the role author the field permissions to create and view own value for such a field of the collection as "Manuscript", but NOT edit own field for that field. But the author can still edit it like removing it or uploading a new one.

Can anyone please tell me how to fix this? Thanks!

mariacha1’s picture

Title: field_collection integration? » field_collection integration -- add hook for defining entity's owner
Issue summary: View changes
Status: Active » Needs review
1.38 KB
FAILED: [[SimpleTest]]: [MySQL] 279 pass(es), 11 fail(s), and 0 exception(s). View

It looks like the major issue here is with function _field_permissions_entity_is_owned_by_account(). It's looking for each entity to have a uid property. Here's the code within the function:

  // Try to get the uid of the entity owner from the entity itself. If it's not
  // set (for example, if the entity type does not store a uid or does not have
  // a concept of "ownership"), we need to assume that the provided user
  // account does not own it.

However, with field collections, there IS no defined uid per entity.

What do you think of adding a hook to allow other modules to modify the assigned userid?
hook_field_permissions_userid_ENTITY_TYPE_alter(&$uid, $entity)

Adding this hook could be the first step to getting field collections to work with field permissions.

Patch attached.

Status: Needs review » Needs work

The last submitted patch, 6: field_permissions-add_userid_hook-1284016-6.patch, failed testing.

mariacha1’s picture

Status: Needs work » Needs review
1.43 KB
PASSED: [[SimpleTest]]: [MySQL] 296 pass(es). View
673 bytes

Sorry, broke tests. New attempt (with diff between it and #6).

Renee S’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

I've been using this solution (in combination with Field Collection) for quite awhile now on a few sites. No problems so far.

sdudnik’s picture

Renee S, do you using dev versions of both modules?

ron_s’s picture

@sdudnik, I've been using the main releases with these patches, and have had no issues. More specifically, the module versions I'm using are Field Permissions 7.x-1.0 and Field Collection 7.x-1.0-beta11.

However, @Renee S is absolutely correct in setting the version to 7.x-1.x-dev. New patches should be applied to the -dev branch, not a release of a module.

webservant316’s picture

Yeah just hit this snafu today.
Fortunately, the patches fix it.

#8 above

Hopefully the field_collections and field_permissions maintainers are on board with the patches.

  • mariacha1 committed 665ccfd on 7.x-1.x
    Issue #1284016 by mariacha1, adellefrank: field_collection integration...
mariacha1’s picture

Status: Reviewed & tested by the community » Fixed

Now it is I who am the maintainer! Thanks me from the past! And everyone else. :)

mariacha1’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)

Actually, setting this to Patched (to be ported) so the D8 peeps can review it for relevance.

mariacha1’s picture

Status: Patch (to be ported) » Needs work

Going to see if I can't get this solved in a way that doesn't rely on

mariacha1’s picture

Assigned: Unassigned » mariacha1

  • mariacha1 committed 7823ec0 on 7.x-1.x
    Issue #1284016 by mariacha1: field_collection integration -- implement...
mariacha1’s picture

Status: Needs work » Patch (to be ported)

Pulled this patch into the field permissions module instead:

So this is going back to the d8 branch for evaluation.

mariacha1’s picture

Assigned: mariacha1 » Unassigned