The list of embed display options in the embed dialog is supposed to be restricted by the "Allowed Entity Embed Display plugins" selected on the button configuration page. It does not. It just keeps showing the entire list of options.

The problem traced to inconsistency in how the $available_plugins and the $allowed_plugins arrays are formatted. The base array returned from entity_embed_get_entity_field_formatters() would then be processed in what should've been the same way every time. That extra processing should be consolidated in the function itself to prevent errors like this from happening.

There's good documentation in this area of the code, so I think I can patch this one without having to make too many baseless assumptions about how stuff is intended to work.

Comments

aDarkling created an issue. See original summary.

adarkling’s picture

devin carlson’s picture

Status: Active » Needs review
adarkling’s picture

Rerolled patch to work with current 7.x-3.x-dev release.
Also moved patch #2634350-2 to entity_embed_get_entity_field_formatters() for expanded availability.

froboy’s picture

Patch works for me.

For folks coming here later, I was receiving the message "No display options available for the selected entity. Please select another entity." if I selected any items in display plugins list, even when they existed for the entity I was selecting.

froboy’s picture

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

I have the same issue as froboy.
However, this patch did not fix it for me.

It is easily reproducible with the Commons distribution.
Just limit to any display plugin for the file embed button (/admin/config/content/embed-button/list/file/edit).
Also fails if you "limit" to all the plugins.

adarkling’s picture

Patch still applies & works properly here under 7.50 Core

devin carlson’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new7.84 KB

A reroll of #4 with a few minor changes:

  1. +++ b/entity_embed.admin.inc
    @@ -169,46 +169,11 @@ function entity_embed_dialog_form($form, &$form_state, $filter_format, $embed_bu
           $available_plugins = array();
    

    Immediately overwritten. Removed.

  2. +++ b/entity_embed.admin.inc
    @@ -381,7 +346,9 @@ function entity_embed_dialog_form_validate($form, &$form_state) {
    -            $available_plugins = entity_embed_get_entity_field_formatters($entity_type);
    +            // Retrieve a list of formatters appropriate for the currently selected
    +            // entity type.
    +            $available_plugins = entity_embed_get_entity_field_formatters($entity_type, $entity);
    

    Duplicated comments from above for simplicity.

  3. +++ b/includes/entity_embed.display.inc
    @@ -197,17 +197,60 @@ function entity_embed_get_entity_field_types($entity_type) {
    +function entity_embed_get_entity_field_formatters($entity_type, $entity = null, $as_labels = true) {
    

    Left out $as_labels parameter as it isn't used anywhere. It could be added in a separate issue if necessary.

  4. +++ b/includes/entity_embed.display.inc
    @@ -197,17 +197,60 @@ function entity_embed_get_entity_field_types($entity_type) {
    +      if (!module_exists('file_entity')) {
    +        continue;
    +      }
    

    Users should still be able to embed files when the File Entity module is unavailable, they just can't use the Rendered Entity formatter.

  5. +++ b/includes/entity_embed.display.inc
    @@ -197,17 +197,60 @@ function entity_embed_get_entity_field_types($entity_type) {
    +        else {
    +          $entity_formatters[$info['module'] . ':' . $formatter] = $info;
    +        }
    

    Removed per above comment RE: function parameter.

devin carlson’s picture

Status: Needs review » Fixed

Tested #9 and committed to Entity Embed 7.x-3.x. Thanks!

Status: Fixed » Closed (fixed)

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