Can't get User Attribute Select Options
Permalink
This code in 8.2.1 no longer works
Anyone have the new code for getting a select attributes' options?
This line:
Apparently $at isn't the right type.
Throws this error -
Argument 1 passed to Concrete\Core\Attribute\Controller::__construct() must be an instance of Doctrine\ORM\EntityManager, instance of DoctrineProxies\__CG__\Concrete\Core\Entity\Attribute\Type given, called in /var/www/public/nanostring2017.local/application/themes/nanostring/elements/footer.php on line 63 and defined
$cak = \UserAttributeKey::getByHandle('area_interest'); $at = \Concrete\Core\Attribute\Type::getByHandle('select'); $satc = new \Concrete\Attribute\Select\Controller($at); $satc->setAttributeKey($cak); $values = $satc->getOptions(); if (!empty($values)) { foreach($values as $value) { echo sprintf("<option value=\"%s\">%s</option>", $value, $value); } }
Anyone have the new code for getting a select attributes' options?
This line:
$satc = new \Concrete\Attribute\Select\Controller($at);
Apparently $at isn't the right type.
Throws this error -
Argument 1 passed to Concrete\Core\Attribute\Controller::__construct() must be an instance of Doctrine\ORM\EntityManager, instance of DoctrineProxies\__CG__\Concrete\Core\Entity\Attribute\Type given, called in /var/www/public/nanostring2017.local/application/themes/nanostring/elements/footer.php on line 63 and defined
Thanks, MrK!
I actually wound up doing a bit of digging into some of the Express core stuff and came up with this.
Hope this thread helps someone else! Thanks for the reply!
I actually wound up doing a bit of digging into some of the Express core stuff and came up with this.
$cak = \UserAttributeKey::getByHandle('area_interest'); $options = $cak->getController()->getOptions(); if (!empty($options)) { foreach($options as $option) { echo sprintf("<option value=\"%s\">%s</option>", $option->getSelectAttributeOptionDisplayValue(), $option->getSelectAttributeOptionDisplayValue()); } }
Hope this thread helps someone else! Thanks for the reply!
You can try this: