- Issue created by @apmsooner
- 🇺🇸United States apmsooner
Opening an initial MR to get the ball rolling on this. It's not 100% yet but functioning as expected at least so far.
- 🇮🇹Italy giuse69
hi, so far patch 74 does not work throwing php exception of field unknown
- 🇺🇸United States apmsooner
Try clearing cache and if still errors, please look at your logs and post here anything thats helpful. I'm not seeing any php errors in my testing.
- 🇮🇹Italy giuse69
Hi, I had cleared the cache. The scenario is as follows:
-) one vocabulary "country"
-) another vocabulary "area", where there is a custom field "items" with unlimited values. Its subfields are: "item" that is a reference to "country" and "inclusion" that is the type of inclusion of the country in that area.
-) a view on country vocabulary to show in which areas a country is. Contextual filter = term id, relationship = "Relate each Taxonomy term with a field_area_items_item set to the taxonomy term".
-) Showing field "Taxonomy term: Items" gives no output and there is no PHP error - first problem.
-) Showing field "Taxonomy term: Items:inclusion" throws PHP exception "Uncaught PHP Exception InvalidArgumentException: "Field field_area_items is unknown." at /web/core/lib/Drupal/Core/Entity/ContentEntityBase.php line 616" - second problem.Let me know if you need more info.
thanksGiuse
- 🇺🇸United States apmsooner
The patch sort of works but multi-lingual results in some errors in the view that I'm not able to resolve immediately. The need for individual subfield formatters is low priority for now and I want to focus on getting a stable release out as well as features that hit a broader need.
- 🇮🇹Italy giuse69
Ok, I will wait. Let me just add that, as I wrote in https://www.drupal.org/project/custom_field/issues/3476033 ✨ Support not just values in custom template Active , for me the issue is not on subfields but on the custom field itself: when I try to use a custom field in a view of taxonomy terms in a multilingual site, it never works correctly: either it does not show anything, or it throws a PHP error, or it messes up the query and unrequested taxonomy terms show up.
While if I use directly its subfields in the view, the result is correct, just without the chance of selecting tokens or formatters.
Thanks for your precious work - 🇮🇹Italy giuse69
Hi Andy, will you explicitly write here when the patch is ready for testing?
- Status changed to Needs work
about 1 month ago 2:08pm 30 March 2025 - 🇺🇸United States emilorol
Is there any update on this?
Having multiple fields exposed in the views is working like a charm, we are just missing the part of displaying the values instead of keys.
Will this change be part of the current module?
- 🇺🇸United States emilorol
I tried applying the changes as a patch:
"patches": { "drupal/custom_field": { "Views individual subfield formatter support": "https://git.drupalcode.org/project/custom_field/-/merge_requests/74.diff" } }
and I got the following error:
- Applying patches for drupal/custom_field https://git.drupalcode.org/project/custom_field/-/merge_requests/74.diff (Views individual subfield formatter support) Could not apply patch! Skipping. The error was: Cannot apply patch https://git.drupalcode.org/project/custom_field/-/merge_requests/74.diff In Patches.php line 331: Cannot apply patch Views individual subfield formatter support (https://git.drupalcode.org/project/custom_field/-/merge_requests/74.diff)!
- 🇺🇸United States apmsooner
The patch needs to be started over against the 3.1x branch. Alot has changed since and I havn't had a chance to revisit this. If not this next release, the one after I should get to it.
- 🇺🇸United States emilorol
Let me take a wack at it. I need this functionality for a project.
- 🇺🇸United States emilorol
Thank you for doing that. Let me test it one more time and I will let you know.
- 🇺🇸United States apmsooner
@emilorol, its somewhat more functional now but its NOT at all ready. This turned out to be way more complicated of a task than anticipated. I'm continuing to look work on it when i can but don't anticipate this making it into a release anytime real soon at this point.
- 🇺🇸United States apmsooner
@emilorol,
You can try working with the latest patch. I've mostly adapted cores EntityField implementation (see: core/modules/views/src/Plugin/views/field/EntityField.php) to our new views field plugin: /src/Plugin/views/field/CustomField.php
I havn't handled grouping and theres likely other stuff I've missed when you start messing with multi-lingual and such. The individual formatter settings work fine and the 'Multiple field settings' seems to work correctly.
I think its pretty close but it is quite complicated and can't say for 100% that its correct. It just seems to work at least from what i've tested and provides something solid to build on at this point with some other testing.
- 🇺🇸United States emilorol
Having some issue apply thing patch with the 3.17 version:
"patches": { "drupal/custom_field": { "Views individual subfield formatter support": "https://git.drupalcode.org/project/custom_field/-/merge_requests/74.patch" } }
Getting this error:
- Installing drupal/custom_field (3.1.7): Extracting archive - Applying patches for drupal/custom_field https://git.drupalcode.org/project/custom_field/-/merge_requests/74.patch (Views individual subfield formatter support) Could not apply patch! Skipping. The error was: Cannot apply patch https://git.drupalcode.org/project/custom_field/-/merge_requests/74.patch In Patches.php line 331: Cannot apply patch Views individual subfield formatter support (https://git.drupalcode.org/project/custom_field/-/merge_requests/74.patch) !
- 🇺🇸United States emilorol
@apmsooner,
Other than copy the changes manually I don't understand why I can't apply the patch.
Meanwhile I want to ask you, this patch will allow me to apply the subfields formatter when consuming them from a view, correct?
Example:
Before applying the patch:
After applying the patch:
Also will this solve the issue with expose view filters that give me a text field instead of a dropdown?
Note: in order for the status to display like a dropdown I had to use grouped filters
- 🇺🇸United States apmsooner
@emilorol,
From your screenshots, the sub-formatter appears to be working for you so I think your question is answered there no?
As for the filters, no this patch will not address any new filters. I don't really have a solution for select field filters as the field type could be shared across other entity bundles and have different widget settings so there's just not gonna be a way to do that for that reason. Looks like you found a workaround with Grouped filters for now.
- 🇺🇸United States emilorol
No, the sub-formatter is not working for me yet as I have not been able to apply the patch, but I wanted to confirm we were talking about the same thing that is why I provided the screenshots. Very glad that we are.
About the filters I think that in the mid time beside the Grouped filter the other thing I have left if using code in the exposed filter form alter hook from the views.
All of this makes me think if there is a way to "trick" entity/form API to see the sub-field as a regular field for the widgets, formatters and exposed filters so that everything does not have to be re-implemented.
Note: for the patch could it be that it needs to rebase it so that I can apply it to the latest version?
- 🇺🇸United States apmsooner
@emilorol,
I would probably just composer remove your local custom_field module and do a git pull of this branch directly into your modules/contrib if your still having problems applying the patch. I just merged dev into this branch that has alot of changes as well. If you use ddev, just do a ddev restart if you pull this branch in and then clear the cache.
- First commit to issue fork.