Problem/Motivation

Operations "edit" and "remove" are only available for nodes in edit form (not available for user or taxonomy).

Scenario :
- Create a field collection field on user or taxonomy
- Add a field in this new field collection
- Create a user or taxonomy term with a field collection item, operations "edit" and "remove" will be displayed
- Save the user or the taxonomy term
- Edit it, operations will not be displayed (only works with node)

The problem seems to come from the checkAccess() in FieldCollectionItemAccessControlHandler, which try to retrieve the host entity and check the access.
For User or Term, it doesn't work because FieldCollectionItem getHostId() check non existing table for field (ex: taxonomy_term_data_test instead of taxonomy_term__field_test).

Proposed resolution

Fix the table name construction to make it works with other entities than node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeanfei created an issue. See original summary.

jeanfei’s picture

Assigned: jeanfei » Unassigned
Status: Active » Needs review
FileSize
784 bytes

Here the patch working for me :
- drupal-8.0.5
- field_collection-8.x-2.x-dev
- inline_entity_form-8.x-1.0-alpha5

Blanca.Esqueda’s picture

Same issue.
But now in Drupal 8.1 not even the add field collection item is available.

Blanca.Esqueda’s picture

Status: Needs review » Reviewed & tested by the community

HI,

Applied the patch and it is working for Drupal 8.05 and Drupal 8.1

Thank you @jeanfei

ademarco’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.26 KB

I've re-rolled patch at #2 by solving the @todo in the same method where the patch was applied.

bircher’s picture

Status: Needs review » Reviewed & tested by the community
vasyl.kletsko’s picture

Applied this patch in Drupal 8.1.3 and it`s working

jmuzz’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

8.x-2.x is no longer being developed or supported.

woprrr’s picture

Just one think...

  1. +++ b/src/Entity/FieldCollectionItem.php
    @@ -302,11 +302,15 @@ class FieldCollectionItem extends ContentEntityBase implements FieldCollectionIt
    +        $table = $entity_info->get('id') . '__' . $this->bundle();
    

    You should use directly helper (standard) specific method $entity_info->id(); to get identifer.

  2. +++ b/src/Entity/FieldCollectionItem.php
    @@ -302,11 +302,15 @@ class FieldCollectionItem extends ContentEntityBase implements FieldCollectionIt
    +            ->select($table, 't')
    

    Instead of these $table you should use https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%... is more safe.