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


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.

  • Comments have been removed. Please don't use them for extended discussion. – kiamlaluno Jun 23 '16 at 20:34

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

{{ content.field_position[0]['#markup'] }}
  • 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 Jun 23 '16 at 10:05
  • Yes, I agree, this is a quick fix. – Oana Hulpoi Jun 23 '16 at 10:58

To get the raw value use:

{{ content.field_position.0 }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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