- Issue created by @apmsooner
- 🇺🇸United States apmsooner
Patch available for testing. Recommend clearing cache.
In the formatter settings for the 'default' formatter. Theres a new details element labeled "Style settings" under each field. These settings allow to set the html wrapping element and add additional classes.
- 🇮🇹Italy giuse69
Hi Andy, it works for me with just a small typo: when the label is shown when using the default formatter, an extra space/blank is added before the colon, like "label : value".
As a side note not directly related to this issue but to the formatter in general:
-) the custom formatter cannot be translated and it should be since we can write words in the template (both basic and advanced).
-) in the advanced template, I couldn't find a way to show the label of the subfield (I found no token for that), should it be added?Thanks
Giuse
- 🇺🇸United States apmsooner
Thanks, i just pushed up a fix for the extra space. Just get the latest patch and clear cache and should be good.
Other issues...
1. You're saying not the tokens themselves but the text you also put in there? Let me look into that for you as I didn't think of that issue honestly.
2. There are tokens for every label of subfield. It would be like this example: [node:field_testing:value:label]. In the token browser, you should be able to expand the subfield and see label.ie explained format; [entity_type:field_name:subfield_name:subfield_label]
- 🇺🇸United States apmsooner
For #1, Are you translating the configuration page for that I assume?
- 🇺🇸United States apmsooner
From what I can tell, it doesn't look like Drupal provides a way to translate display page settings. Might be out of luck on that one as I just don't see an option for that.
- 🇮🇹Italy giuse69
Hi Andy, for #1... ok, Drupal effectively does not allow to translate display settings so my request is not easy. maybe allowing twig support in the template? That would greatly enhance flexibility of the advanced template, also enabling translation.
About #2, I mean the labels that represent the name of the subfield, not the labels/values corresponding to the raw values. I didn't find any token for the names of the subfields, the same output obtained with [:label] with basic template.
- 🇺🇸United States apmsooner
1. Handling twig support in that field is something I don't want to do. If you're comfortable with twig, you can just copy the field templates from custom_field or even just have a higher level core field template in your custom module or theme that you can customize to your desire. This template formatter for custom field was never really meant to be a full on replacement for theming but more as a solution for simple output.
2. The labels are exposed in the token browser but if you're not seeing them, it may mean that you may have too low of a setting for recursion limit which the default in Drupal core is 3. If you are using paragraphs and such, you sometimes need to increase this to 4 or 5 maybe to get deeper into the tree. I've included a field that applies that in the advanced tokens settings for the custom template formatter that you could try modifying. Just know that increasing the recursion limit loads the tree slower.
Overall, I think going down this tokenized template route might not be the best solution for you and I'd probably recommend customizing your own field templates.
-
apmsooner →
committed 6783611a on 3.0.x
Issue #3496708 by apmsooner, giuse69: Formatter wrapper tags, classes,...
-
apmsooner →
committed 6783611a on 3.0.x
- 🇮🇹Italy giuse69
About #2, I can confirm you that I can't see any token for the subfield names, even with 5 levels depth. The practical example: a paragraph with a custom_field "CF" with a integer select list subfield named "status" that has value = 0 and label= "NO".
Here are the tokens and their outputs:[paragraph:CF] =>
status
NO
[paragraph:CF:status] => 0
[paragraph:CF:status:label] => NO
[paragraph:CF:status:value] => 0so no token contains the string "status" that is the name of the subfield (except for "paragraph:CF" but that contains all the custom field, not just the subfield name).
With the basic template, [status:label] outputs "status" as needed.
Any idea?
thanks - 🇺🇸United States apmsooner
Okay, i was probably thinking about the list options label. Follow this task and I'll have a patch for you: https://www.drupal.org/project/custom_field/issues/3498012 ✨ Add field label token for custom template formatter Active