I'm using the Paragraphs module to create components, i then make a content type and add the Paragraph as a reference field.
The form of the Paragraph has a field (a list) where a content creator can select a color name for a background color for the div. Each Paragraph has 3 values (pacific_blue, smokey_white, white).
However, i'm trying to get the selected value without displaying it on the site.
As long as the field is not disabled i can get the value using this code and add the class to style the div with the right background color:
<div class="c14a {{ content.group_wrap.field_color_backgrou d.0["#markup"] }}">
<div{{ attributes.addClass(classes) }}>
{{ content }}
</div>
</div>
So how do i get the value of a field that is disabled in 'manage display'?
Thx...
I have just implemented similar functionality to a site I am building. In my case the content creator can make a selection from a dropdown and depending on the selection a particular class is applied to a div.
My issue was similar in that I wanted to extract the raw value of the field without display the field on the front end. The problem I encountered was that disabling the field prevented me from getting the raw field value in the twig template.
The solution that I came up with was to use a preprocess function instead of disabling the field which allowed me to remove the field from the front end while still allowing me to access the field value in my template.
function HOOK_preprocess_YOUR_FIELD(&$variables)
{
unset($variables['items']);
}
Hope this answer is of some help to anyone out there