Support from Acquia helps fund testing for Drupal Acquia logo

Comments

plach’s picture

Status: Active » Postponed
FileSize
8.2 KB

This has been rolled while working on #1280546: Introduce a language selection widget for every entity thus won't apply to HEAD until that one is committed.

Reviews welcome anyway.

plach’s picture

Status: Postponed » Needs review

Now we are ready for bot review.

bforchhammer’s picture

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

Permission change looks fine.

I think the bundle/id properties should actually be set by the setEntity() method to make sure they always match the wrapped entity... as far as I can see, this also means that we can remove the $entity_id constructor argument.

plach’s picture

#3 was addressing two completely different issues in one patch. I split them: #1799770: Update id and bundle when setting a wrapped entity.

Committed and pushed the relevant part.

plach’s picture

Status: Reviewed & tested by the community » Fixed
bforchhammer’s picture

Makes sense, thanks.

bforchhammer’s picture

Status: Fixed » Active

I'm afraid this issue needs a little more work...

From #1495570-20: Update Entity translation integration:

One minor thing: the "Product SKU" and "Status" fields are not marked as "shared fields" (i.e. no "translatability clue") but are treated as them (i.e. changes in one language affect the other language). This will need to be changed in the ET module, so as far as this patch is concerned I'd say it's RTBC :)

Also, the behavior around what is considered a shared field in which cases has grown inconsistent; for "fields" (changed field_attach_form_alter), the fields is only hidden on translation forms, whereas properties (change by the committed patch) are also hidden on the source edit form. Fields also do not respect the entity-type specific shared fields permission yet.

I'm working on a patch...

plach’s picture

You are right, there is an inconsistency: I think one should be allowed to edit shared fields only if she has the related permission, we will then have an #1770748: Option to display shared fields only when editing the original values to match the current field behavior.

bforchhammer’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
7.02 KB

Attached patch tries to fix both issues mentioned above.

With commerce products we now have a "(shared field)" suffix on titles for the following elements: Product SKU, Price, Status and Change history.

plach’s picture

Status: Needs review » Needs work
+++ b/includes/translation.handler.inc
@@ -1075,20 +1075,37 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
+   * Fields are handled separately in entity_translation_field_attach_form().

Can we handle everything here? I don't think we have a particular reason to deal with fields in a separate place, and that makes the logic harder to follow.

+++ b/includes/translation.handler.inc
@@ -1075,20 +1075,37 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
+  private function entityFormSharedElements(&$form) {

Why private?

+++ b/includes/translation.handler.inc
@@ -1075,20 +1075,37 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
+    $ignored_elements = array_flip(array('language', 'translation'));

This should not be needed, as the language widget and the translation settings do have an #access key.

+++ b/includes/translation.handler.inc
@@ -1075,20 +1075,37 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
+        $form[$key]['#translatable'] = FALSE;

This looks promising, however I think in the future we will need a more reliable way to determine whether a widget is multilingual or not, and enforce shared access based on that, even if we already have an #access key. I'm thinking about a '#multilingual' key instead of '#translatable' (which is more specific) that we would assign to core form elements (fields included) and we would ask other modules to provide to integrate with ET. It would simply be ignored if ET is not installed. This must be a follow-up though, as we need to ensure modules actually accept this integration stuff.

This is already planned for D8, btw: #1498724: Introduce a #multilingual key (or similar) for form element.

bforchhammer’s picture

A new patch should also consider #1802452: Notice for form elements without a #type.

plach’s picture

Marked that one duplicate. Let's not forget about crediting @Berdir in the changelog and commit message.

plach’s picture

Assigned: Unassigned » plach

Working on this.

plach’s picture

Assigned: plach » Unassigned
Status: Needs work » Needs review
FileSize
15.38 KB
14.13 KB

The attached patch fixes #10 and adjusts the update function 7002 to cover also shared fields permissions.

Status: Needs review » Needs work

The last submitted patch, et-shared_fields-1798456-14.patch, failed testing.

plach’s picture

Status: Needs work » Needs review
FileSize
14.77 KB
1.98 KB

Actually we want to prevent access only to the entity form fields: hook_field_access() was too much.

bforchhammer’s picture

Status: Needs review » Reviewed & tested by the community
bforchhammer’s picture

Cool, looks good to me. I'll commit your patch with minor changes in a minute...

bforchhammer’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks! :)

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

  • Commit 0c3a3f6 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions by plach:
    Issue #1798456 by plach: Hide shared form elements when the user has not...
  • Commit cbf6b9a on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions by bforchhammer:
    Issue #1798456 by plach, bforchhammer, Berdir: Hide shared form elements...

  • Commit 0c3a3f6 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench by plach:
    Issue #1798456 by plach: Hide shared form elements when the user has not...
  • Commit cbf6b9a on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench by bforchhammer:
    Issue #1798456 by plach, bforchhammer, Berdir: Hide shared form elements...