Get options for select attribute in v8

Submitted by remo - 3 months ago

If you have a select attribute in concrete5 version 8 and wish to get the options for it, use the code below

$attributeKey = CollectionAttributeKey::getByHandle('select');
/** @var \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption[] $options */
$options = $attributeKey->getController()->getOptions();
foreach ($options as $option) {
    echo $option->getSelectAttributeOptionID() . ': ' . $option->getSelectAttributeOptionValue();
}
Stats Categories Tags
comments powered by Disqus