2

I have a multi-select field in my work section

enter image description here

I want to get the values either with the Element api as json or an array of simple values in my template.

2
  • Do you want every possible value for the field? Or all of the selected values for the field on an element (i.e. entry, user, etc.).
    – Brad Bell
    Commented Jul 31, 2018 at 23:28
  • Hi Brad, every value.
    – LeBlaireau
    Commented Aug 1, 2018 at 4:35

1 Answer 1

1

$element->getFieldValue('handle') or it's Twig equivalent element.handle contains an Object of type MultiOptionsFieldData you can get all possible values via itsgetOptions()` function

Twig

{{ dump(entry.fieldHandle.getOptions()) }}

PHP

$options = $element->getFieldValue('handle')->getOptions();

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.