- First commit to issue fork.
- 🇬🇧United Kingdom scott_euser
Correct if you are using latest merge request. The automated test coverage has to do the same thing in order to test the filter, so you can see that code here applying to all entity reference fields that are currently set to use string or numeric filters: https://git.drupalcode.org/project/drupal/-/merge_requests/4053/diffs#2f...
With such code applied (replacing with your own module name instead of that module which is named "views_test_entity_reference"), after clearing cache, adding a new filter with entity reference should show you the entity reference options rather than numeric options for example.
- 🇫🇷France nod_ Lille
First of all thank you all for the hard work on this one, I've had to push a number of patches like this and I know how hard it is to keep up.
I'm going to try and refocus the jQuery removal work and to do that I need to take a few decisions. I'm going to close this issue for a few reasons:
- This MR is big, it impact a very big number of subsystems and make the code more brittle. jQuery is good at dealing with undefined elements, empty sets and so on, the DOM isn't. We already had regressions from a previous patch with undefined elements
- The MR is too big to review and make sure there are no regressions (even with the tests we already have), it would create unstability that we don't have to endure
- Sometimes the jQuery code is simply more readable, I do not think this change is a net positive:
$(once('filter-guidelines', '.js-filter-guidelines', context)) .find(':header') .hide() .closest('.js-filter-wrapper') .find('select.js-filter-list') .on('change.filterGuidelines', updateFilterGuidelines) // Need to trigger the namespaced event to avoid triggering formUpdated // when initializing the select. .trigger('change.filterGuidelines'); // Define the closest function for finding the closest ancestor with a given selector function closest(element, selector) { while (element && !element.matches(selector)) { element = element.parentNode; } return element; } const contextElement = document.querySelector('.js-filter-guidelines'); const closestWrapper = closest(contextElement, '.js-filter-wrapper'); if (closestWrapper) { const $context = $(contextElement); const selectElement = $(closestWrapper).find('select.js-filter-list'); $context.find(':header').hide(); selectElement .on('change.filterGuidelines', updateFilterGuidelines) // Need to trigger the namespaced event to avoid triggering formUpdated // when initializing the select. .trigger('change.filterGuidelines'); }
There is one line to change and we have to make many, many other changes for this to work
I ported the credits to 📌 Credit for work on the reduce jQuery issues Active , which I will mark as fixed as soon as I go through all the others impacted jQuery issues.
- 🇨🇦Canada jodavidson
Thanks @scott_euser.
If I understand the summary notes. I create a basically empty custom module that really only has the hook_views_data_alter() snippet in its MODULE.module file. And the patch should take effect once the custom module is activated?
Hello,
I found the issue exists in the current version, so I have raised the MR!3 for the same and updated the version.
I would be glad to hear from the maintainer if we need to create a separate field for color selection, so that heading containing links can be more customizable. For now I have implemented the color scheme similar to that of the other links (e.g. read more, add comments) present when a article/basic page is created.
I have added the ss for both without hover and with hover, before and after changes.
Please have a look.
Thanks- @esha_kundu opened merge request.
- First commit to issue fork.
Is there any documentation about how `#config_target` should/can be used?
- 🇺🇸United States en-cc-org
Our site is also frozen at 10.2.7, but (not realizing patch #453 would work), I applied this patch https://www.drupal.org/files/issues/2024-04-17/3347343-comment156-10.2.x... → As mentioned, this patch required me to rebuild my views to use the new "field_name as a reference filter". All is stable for now. Thankful to those continuing to find solutions as we are very dependent on this feature.
- 🇬🇧United Kingdom scott_euser
Hi @jodavidson,
Essentially the problem with making a separate reference field (the 'as a Reference' that existed in some versions of the patch) would be very hard to merge back later.
Then the problem of replacing all existing Entity Reference filters on place is that the current Numeric filter offers more options (like all node IDs > 100) that would be lost and therefore it'd be a breaking change.
So the current status is to provide the Entity Reference filter but not actually make use of it (some follow up tasks to allow a content editor to use it via the UI). Splitting into follow-ups means we can actually get it to land (hopefully) but making this scope significantly less risky.
There is a code snippet in the issue summary now that shows how to make use of the latest merge request, but assuming we get framework manager approval I'll create a module in contrib that effectively does that for now until the follow-ups land (on the framework manager approval @catch noted he wants other eyes to grant that since he's the one who came up with the idea of the above).
So tiny bit of limbo state as I don't want to go make that contrib module unless we are quite confident this will be the agreed direction.
Hope that helps clarify at least (I know it doesn't solve sorry!)
- 🇺🇸United States mmenavas
My site is also frozen at 10.2.7. Let us know how the community can help out.
- 🇨🇦Canada jodavidson
Hello all,
With all the twists and turns this issue has taken I wonder if there is a current solution to getting the Settings option back in place for exposed entity reference filters?
For 10.2.7 the patch here: https://www.drupal.org/files/issues/2021-12-02/2429699-453-9.3.x.patch → worked well. In 10.3.1 I've made a local patch from MR !4053 mergeable (above) and applied it. Unfortunately it does not return the Settings option. Looking at the past few comments maybe it is not supposed to by itself?
Reading through these issue chains is pretty confusing for me, (and many others I imagine,) so I thought it best to ask for some clarification. Personally my site is frozen at 10.2.7 until there is a solution for this issue.
Thanks for your time and work on this issue, it sure looks like a big can of worms that has existed since D8.
- 🇬🇧United Kingdom catch
Reviewed the MR and it all looks good to me.
Retitling because the latest approach doesn't make it available for all entity reference fields yet, that bit will happen in ✨ Configurable views filters to allow for different widgets Active .
Leaving the framework manager review and subsystem review tags because the latest approach was my idea and this issue has a lot of twists and turns.
- 🇨🇦Canada m4olivei Grimsby, ON
Added the empty update function to force a cache clear on update.
The Needs Review Queue Bot → tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
I answer to myself. finally i've solved my issue by fixing 2 points:
The first point was a mistake from my side : the "value" used in the definition must be a "string". In my code, i used an entity reference id defined as an integer.
The second point was linked to my select field defined as a "multiple" one. To address this point it's necessery to alter the "compare" function of core/misc/states.js. I add this js library into my module
/** * @file * Extends core/misc/states.js. */ (function($) { //correction core : can't add a #states on a select with multiple = true function _compareCustom(a, b) { if (a !== "undefined" && typeof b === 'object' && b instanceof Array) { if (b.includes(a)) { return true; } } if (a === b) { return typeof a === 'undefined' ? a : true; } return typeof a === 'undefined' || typeof b === 'undefined'; } //hack : surcharge function compare from core/states.js to use _compareCustom instead of _compare2 Drupal.states.Dependent.prototype.compare = function compare(reference, selector, state) { var value = this.values[selector][state.name]; if (reference.constructor.name in Drupal.states.Dependent.comparisons) { return Drupal.states.Dependent.comparisons[reference.constructor.name](reference, value); } return _compareCustom(reference, value); }; })(jQuery);
This solution works with all drupal version from 8.x to 10.3.1.
- 🇬🇧United Kingdom scott_euser
Thanks! Updated issue summary post tasks as per #218
Sorry, but the last version of Drupal 10.3.1 break all my "select" based conditional fields.
My conditional fields works well on Drupal 10.2.6Here an extract from my form where the field_child is visible when the taxonomy term (tid:1234) is selected
$form['field_child']['#states'] = [ 'visible' => [ ['select[name="field_parent[]"]' => '1234', ], ];
- 🇬🇧United Kingdom catch
This feels like it might unblock things. Short version of how we get to the original end result assuming everything currently being worked on comes together:
1. Add the new filter here, but not automatically to views data yet.
2. Do 🐛 Views handler loading should respect configuration Active so configuration is respected in views.
3. After #2, do ✨ Configurable views filters to allow for different widgets Active to allow the filter plugin to be selected in the UI. This would be an extra UI element in views, plus some kind of API for plugins or fields to declare compatibility with each other tbd.
The for entity reference fields, there'd be a choice of numeric and entity reference, and site builders can choose which one, and we don't have an upgrade path or bc concern specific to the entity reference change - although there is still quite a lot of that in #2 and #3 overall.
- 🇬🇧United Kingdom scott_euser
As discussed in Slack here as suggested by @catch, the change to views data & views data alter has been reverted and the EntityReference filter is made available without being used, allowing it to be used in place, rather than with the 'as a Reference' duplicate filter.
The issue summary has been updated with a code snippet of how to use and a contrib module automatically opting into this will be provided assuming the direction is accepted and ready to merge. That contrib module could also be used to provide any upgrade path away from the 'as a Reference' in case any sites are making use of the patch.
Tests have been updated to match without any functional change to the tests other then to stop referring to the _reference/'as a Reference' aspect of the filter.
The issue summary has also been updated to match this change in general.
Finally, the change record has been updated, though could use someone to update the screenshots when this is ready to merge.
- 🇳🇿New Zealand quietone New Zealand
The release managers discussed this at the end of May and I am only now commenting. We noted that this is part of the Workflow Initiative but that initiative has ended and there isn't anything here for us to review. We also are aware that there is the Trash module and a core issue to move that to core, 📌 Add experimental Trash module Active .
This issue was also closed; as won't fix in 2017 and then re-opened in 2019. But since then there has been no activity here despite a prompt for more information 2 years ago. After 5 years without comment here from someone from the workflow initiative it seems sensible to restore the won't fix from 2017.
And, if that there is a desire to add this to core, then it would be better to start fresh with a new initiative or plan. Therefore, I am going to close this. I trust someone will correct that if it is wrong.
- 🇬🇧United Kingdom catch
Also if we were to add this, I think it should be its own filter doing this generally for all site-relative links, not within the file reference filter.
For example https://www.drupal.org/project/rel_to_abs → provides this in contrib.
- 🇬🇧United Kingdom catch
The issue summary doesn't explain the problem with relative URLs, why is this a problem?
Additionally, Drupal sites can be run from multiple domains, using domain module and similar. Relative URLs allow this to work, I don't think we're able to cache text formats by arbitrary cache contexts so it would probably break that.
- 🇬🇧United Kingdom catch
Moving this to a plan.
We discussed the general problem (on-the-fly table creation and transactions) at Drupal dev days but I don't think that discussion made it back into an issue, this is probably the right one.
Generally, I still think it's a good idea to make database-implementations-of-services (cache, lock, flood etc.) responsible for creating their database schema, so that if you have a redis backend installed, you don't have 10 empty cache tables in your database for no reason.
However, we could use an interface + tagged services to allow those services to create their schema during module install at an explicit point, so that the fallback is only necessary if you change services.yml to switch an implementation (e.g. from redis to sql) on runtime. And we could maybe do the same tagged services check on a cache clear all so that sites can trigger table creation without having to wait for an entity save or something to do it for them.
This way we'd still have on-demand table creation but we'd be able to... demand it.
- 🇺🇸United States pbabin
I'm in Drupal 10.3.1 using Mercury Editor, Layout Paragraphs and Paragraphs.
We are getting the following error when editing a node with the above setup with a particular paragraph type which is referencing an image (the image is not using a view to render - it is default).
This entity (paragraph: [paragraph id #]) cannot be referenced.
I found initially that I could clone the entity, delete the original, and then save the node. However, on the next edit the issue still remained.
I tried the patch from 39 and could not apply it.
I tried the patch from 38 and it addressed my specific issue.
- 🇮🇳India ehsann_95
I am not able to reproduce the issue. Attaching screenshots for reference
- 🇫🇷France nod_ Lille
I'd like to get this in 10.3 so we need an update function to make sure cache gets cleared (per catch)
- 🇷🇸Serbia finnsky
Fixed feedback.
Also if your site uses navigation today it breaks it until you clear the cache. Should we have an empty update function to make sure it's done?
we have ticket in SDC. I just set its prio to major.
https://www.drupal.org/project/drupal/issues/3460598 🐛 Single directory component CSS asset library not picked up in admin theme immediately after module install without cache clear ActiveI don't know. Navigation is still experimental.
- 🇫🇷France nod_ Lille
Thanks, just a dependency missing for safe triangle lib.
Also if your site uses navigation today it breaks it until you clear the cache. Should we have an empty update function to make sure it's done?