I have a node type where a field_collection field is embedded. (Embed widget).

http://drupal.org/project/field_collection

This brings redirect to add not only a vertical tab for adding redirects to the node, it also adds a tab for adding redirects to the field collection. see Screenshot. I am not quite sure that this will produce problems but it makes not much sense to have an another add tab there as field collection is not meant to get displayed as stand alone content.

I tried to use the migrate support patch http://drupal.org/node/1116408#comment-4844614 #1116408: Support migrate module: Destination handler class and actually it is not working. No redirect is created for the migrated node. Maybe redirect or migrate has a problem to determine which is the right entity id where the redirect should point to because of the field_collection in this node.

I will investigate further an try another migration with a "normal" node and see if it is working there. If this is the case I will post a review to the patch at #1116408: Support migrate module: Destination handler class.

regards
marcus

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcusx’s picture

Title: Redirect node element is doubled if a field_collection is embedded into that node type » Redirect gui tab is multiplied for each field_collection item in a node whith a field collection
FileSize
128.43 KB

Ok it is even worse. For each field collection item we will get a vertical tab. And the counter of how many redirects are existing is also wrong. See attached screenshot.

marcusx’s picture

Title: Redirect gui tab is multiplied for each field_collection item in a node whith a field collection » Avoid redirect field and form injection on entities that have a path but where this makes no sense (like comments)
Status: Active » Needs review
FileSize
3.2 KB

The enclosed patch adds an array with "activated entities" against we check if a redirect field should be attached to an entity. My suggestion is to add the population of this array to the admin interface. Or let the user add the redirect field manually to an entity.

'User' and 'Node' entities could still get the field and the vertical tab automatically for easier usage.

Dave Reid’s picture

This is the better way to support this. Please test the following patch and add 'redirect' => FALSE to field_collection_entity_info().

mstrelan’s picture

Thanks Dave, this works as expected, though instead of patching field_collection.module I altered it in my own custom module.

<?php
/**
 * Implements hook_entity_info_alter().
 */
function MYMODULE_entity_info_alter(&$info) {
  if (isset($info['field_collection_item'])) {
    $info['field_collection_item']['redirect'] = FALSE;
  }
}
?>
alanburke’s picture

I've applied that patch to redirect, and also implemented an alter as described above.
Patch works correctly.
Thanks.

mstrelan’s picture

Status: Needs review » Reviewed & tested by the community

Sounds like this is RTBC to me

droath’s picture

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

I rerolled patch #3, with the added benefit of the site builder being able to choose what entities that the redirect module gets applied too. The additional settings were added to the redirect settings page '/admin/config/search/redirect/settings'. By doing it this way we don't have to worry about applying patches to the field collection module or creating a custom module to implement a cleaner UI. Thanks!

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review

Please leave a UI separate from the issue.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +D7 stable release blocker
BWPanda’s picture

Status: Needs review » Reviewed & tested by the community

Judging by Dave's comment in #8, this should be RTBC for the patch in #3.
Also marked #1340354: How do I remove URL Redirect Field for a Field Collection? as a duplicate of this issue.

BWPanda’s picture

Patch from #3 didn't apply for me, updated patch for latest version of code.

maximpodorov’s picture

commerce_order entity should be in the stop list also.

maximpodorov’s picture

And commerce_customer_profile entity should be in the stop list also.

droath’s picture

I have been working on a field attach UI module. It has an option that will allow you to hide attached fields for a given entity. I found this might be a better approach to solve this type of issue. It's currently a sandbox project, but once I get some feedback on this module, I plan on releasing a full version.

Please post any issues that you have in the field attach UI module issue queue.

https://drupal.org/sandbox/droath/1349866

pjcdawkins’s picture

The patch in #11 applies cleanly. However I'm not quite sure what it should do - I still get redirect fields on my custom entities for which I've specified 'redirect' => FALSE,

pjcdawkins’s picture

Actually it did work: the Redirect elements are no longer injected into forms for entities that have 'redirect' => FALSE.

But redirect_field_extra_fields() still doesn't respect redirect_entity_type_supports_redirects().

kevinquillen’s picture

I am having this same issue with Field Collections where URL Redirects is attaching to every instance of a field collection item within the table row. Which one of the above patches will remove it from the GUI? Patch #11?

Shadlington’s picture

#11 + #4 works for me.

tirdadc’s picture

Ditto, thanks for this.

mrfelton’s picture

Patch in #11 + code in 4 works well.

jwilson3’s picture

Comment #20++

bdone’s picture

#11 + #4 works, thanks!

tanc’s picture

Patch in #11 works for me too. For some reason #4 didn't work even after clearing caches. Implementing the hook_entity_info_alter() from #4 appears to be a requirement but doesn't work without the patch in #11.

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

lsolesen’s picture

mthomas’s picture

Issue summary: View changes

I've filed a similar issue w/patch for the relation module #2321509: Prevent relation module from altering relation forms.

solideogloria’s picture