I've written too many alter hooks to get rid of this, so here's a patch to add it as a formatter setting.

The main thing the argument does is control the h2 title in the default entity template, in a lot of cases, that doesn't make and hiding it in a different way requires either custom code or something like Display Suite, which again afaik only works for entities that have an exposed manage display page. I have a whole set of remote entities which are not fieldable and frequently embedded into pages using entity reference.

Not sure if this needs an upgrade path, we could also just make the check conditional :)

Patch coming soon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
1.57 KB

Here's a patch, is working nicely for me. Not sure about summary (there's only so much space to show something) and the description that I added. Hard to find a mix of useful information and obvious information as that can of course be said about most settings. But I think it makes sense here as that setting will not do anything for DS'ified entities...

Berdir’s picture

Did a !empty() check in formatter_view() so that doesn't result in a notice if not set but just noticed that I forgot to do that in the settings form.

Berdir’s picture

Updated that check to use !empty() as well.

Berdir’s picture

Actually the setting is the wrong way round.

amateescu’s picture

+++ b/entityreference.module
@@ -1076,6 +1077,13 @@ function entityreference_field_formatter_settings_form($field, $instance, $view_
+      '#description' => t('Hide the label of the referenced entity. Only works if not otherwise overwritten.')

Hm, this comment is a bit superfluous.. anything can be overridden :/ Otherwise, this looks good to me.

Berdir’s picture

Yes, I wasn't sure about that either. But most other settings at least require code to override it. This is different, using something like panelizer or DS is enough to completely bypass the setting, it only works with the default templates.

Berdir’s picture

Re-roll, context changed a bit, removed the message. The old patch still applies if you use git apply -3, so it's up to you which one you prefer :)

Berdir’s picture

Status: Needs review » Needs work

The last submitted patch, 8: entity-reference-page-setting-1995562-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

That's a problem with views, unrelated to the patch: #2866162: Plan for Views 7.x-3.18 release, #2903006: Fix tests for 7.x-3.x