5

I have a integer selection list field in my content types with some key|Value options.

0|CEO
1|CTO
2|Manager

now in my template I want get value. I try {{node.field_positon.value}} but it return me key value (it return 0 or 1 or 2 ).

My question is how can I get value of selection option in template file?

notice: I know I can paly with content.field_position ( but it put some markup wrappers around field),I want get it by node variable.

1
  • Comments have been removed. Please don't use them for extended discussion.
    – apaderno
    Commented Jun 23, 2016 at 20:34

2 Answers 2

5

Just use the following, and you will obtain what you want to achieve.

{{ content.field_position[0]['#markup'] }}
2
  • Although I think maybe there is better solution in future but It solved my problem, thank you for attention and spend time to find a solution.
    – Yuseferi
    Commented Jun 23, 2016 at 10:05
  • Yes, I agree, this is a quick fix. Commented Jun 23, 2016 at 10:58
2

To get the raw value use:

{{ content.field_position.0 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.