{"id":7003,"date":"2014-05-16T08:58:21","date_gmt":"2014-05-16T08:58:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/how-to-limit-entity-reference-to-only-allow-referencing-of-nodes-with-the-same-or-undefined-language-collection-of-common-programming-errors\/"},"modified":"2014-05-16T08:58:21","modified_gmt":"2014-05-16T08:58:21","slug":"how-to-limit-entity-reference-to-only-allow-referencing-of-nodes-with-the-same-or-undefined-language-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/16\/how-to-limit-entity-reference-to-only-allow-referencing-of-nodes-with-the-same-or-undefined-language-collection-of-common-programming-errors\/","title":{"rendered":"How to limit Entity Reference to only allow referencing of nodes with the same (or undefined) language?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m looking for the same thing.<\/p>\n<p>The closest I got was by using the current user&#8217;s language. The current user&#8217;s language will be determined by what you select in <code>\/admin\/config\/regional\/language\/configure<\/code>.<\/p>\n<ul>\n<li>add relationship &#8220;Entity translation: translations&#8221;<\/li>\n<li>add filter &#8220;Entity translation: Language (=Current user&#8217;s language)&#8221;<\/li>\n<\/ul>\n<p>Also, this link cleared the field_title issue for me: https:\/\/drupal.org\/node\/1327012.<\/p>\n<p>So, for example, going to <code>\/en\/node\/add<\/code> will populate the entity view with the referenced entities in English. But, if the user changes the language on the edit form the view will remain the same.<\/p>\n<p>This solution would suffice if the referenced entities were the same in all languages and simply translated (like the &#8220;localize terms&#8221; functionality that that core taxonomy translation provides).<\/p>\n<p>The only other &#8216;quick and dirty&#8217; way I can think of is editing the output of the title field in views and adding a css class according to the language. Then writing some jquery that shows\/hides the entities by mapping the class of the entity in the view to the language selection field.<\/p>\n<p>*<strong><em>Ideally, the entity view should repopulate via ajax according to the language selected in the node edit from.<\/em>*<\/strong><\/p>\n<p>If anybody has any ideas please let us know.<\/p>\n<p>Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m looking for the same thing. The closest I got was by using the current user&#8217;s language. The current user&#8217;s language will be determined by what you select in \/admin\/config\/regional\/language\/configure. add relationship &#8220;Entity translation: translations&#8221; add filter &#8220;Entity translation: Language (=Current user&#8217;s language)&#8221; Also, this link cleared the field_title issue for me: https:\/\/drupal.org\/node\/1327012. So, for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7003","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7003"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7003\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}