SelectAttributeTypeOption not recognized by C5
Permalink
Hello All
I'm trying to create an advanced autonav block package & written this code into package controller. Concrete5 doesn't recognize "SelectAttributeTypeOption". Any idea why? Am I doing anything wrong?
Thanks
I'm trying to create an advanced autonav block package & written this code into package controller. Concrete5 doesn't recognize "SelectAttributeTypeOption". Any idea why? Am I doing anything wrong?
use Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption as SelectAttributeTypeOption; $attr = CollectionAttributeKey::getByHandle('stack_row'); if( !is_object($attr) ) { CollectionAttributeKey::add($select_att,array( 'akHandle' => 'stack_row', 'akIsSearchable' => true, 'akIsSearchableIndexed' => true, 'akSelectAllowMultipleValues' => false, 'akSelectAllowOtherValues' => false, 'akSelectOptionDisplayOrder' => 'alpha_asc', 'akName' => t('Add sublevel row with grid')), $pkg)->setAttributeSet($att_set); $attr=CollectionAttributeKey::getByHandle('stack_row'); SelectAttributeTypeOption::add( $attr, 'Option 1'); SelectAttributeTypeOption::add( $attr, 'Option 1');
Viewing 15 lines of 17 lines. View entire code block.
Thanks
Hi mnakalay
I'm using version 8.4.0, I know I'm doing something wrong. But cannot find the right solution.
Rony
I'm using version 8.4.0, I know I'm doing something wrong. But cannot find the right solution.
Rony
Any thoughts on this. I'm really in a need to fix this.
This works for me
<?php $service = $this->app->make('Concrete\Core\Attribute\Category\CategoryService'); $category = $service->getByHandle('collection'); $key = $category->getByHandle('stack_row'); if (!is_object($key)) { $pkg = Package::getByHandle('your_package_handle'); $selectAttributeType = \Concrete\Core\Attribute\Type::getByHandle('select'); //the options you want to add to your select attribute $optionsList = ['option 1', 'option 2']; $selectSettings = new \Concrete\Core\Entity\Attribute\Key\Settings\SelectSettings(); $list = new \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOptionList(); $options = []; $displayOrder = 0; foreach ($optionsList as $option) { $opt = new \Concrete\Core\Entity\Attribute\Value\Value\SelectValueOption();
Viewing 15 lines of 33 lines. View entire code block.
Hi mnakalay
Thank you very much for the code. It works for me. If you know how to add them to a set, please share with me.
Thanks
Thank you very much for the code. It works for me. If you know how to add them to a set, please share with me.
Thanks
I'm trying this:
where it throws an exception "Call to undefined method Concrete\Core\Entity\Attribute\Category::getByHandle()"
// Install category 'Car' $akc = AttributeCategory::add('car', AttributeCategory::ASET_ALLOW_SINGLE, $pkg); $service = $this->app->make('Concrete\Core\Attribute\Category\CategoryService'); $category = $service->getByHandle('car'); $key = $category->getByHandle('gear_box'); // <- Exception
where it throws an exception "Call to undefined method Concrete\Core\Entity\Attribute\Category::getByHandle()"
What version are you using?