Programmatically add values to a select attribute from a package
Permalink
I am trying to create a package that generates new page attributes. One of these is a "Regions" drop down. I am able to create the attribute, but I cannot figure out how to populate it with values. Any help is appreciated!
Here is the code in the package controller:
Here is the code in the package controller:
// Grab the collection attribute key category $eaku = AttributeKeyCategory::getByHandle('collection'); // Set the collection attribute key category to editable $eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE); // Add the "Locations" attribute set $cas = $eaku->addSet('location',t('Locations'),$this->pkg, 0); // Create the "Region" drop down $cak = CollectionAttributeKey::getByHandle('regions'); if (!is_object($cak)) { $at = AttributeType::getByHandle('select'); $cak = CollectionAttributeKey::add( $at, array( 'akHandle' => 'regions', 'akName' => t('Region'),
Viewing 15 lines of 33 lines. View entire code block.
You can find the solution on this cheatsheet:
https://github.com/shahroq/whale_c5_cheat_sheet#add-an-attribute...