question about set Attribute in concrete5 8.5.2v
Permalink
$eaku = AttributeKeyCategory::getByHandle('collection');
$eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$evset = $eaku->addSet('proevent', t('Pro Events'),$pkg);
$evsot = $eaku->addSet('proevent_additional_attributes', t('Pro Events Additional Attributes'),$pkg);
$euku = AttributeKeyCategory::getByHandle('user');
$euku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$uset = $euku->addSet('user_set', t('Events Package'),$pkg);
$timen = AttributeType::getByHandle('times');
if($timen==NULL){
$timen = AttributeType::add('times','Time', $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('times'));
}
else if($timen->getAttributeTypeID()==NULL){
$timen = AttributeType::add('times','Time', $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('times'));
}
$multidateAttribute = AttributeType::getByHandle('multi_date');
if(!is_object($multidateAttribute) || !intval($multidateAttribute->getAttributeTypeID()) ) {
$multidateAttribute = AttributeType::add('multi_date', t('Multi Date'), $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('multi_date'));
}
$colorpicker = AttributeType::getByHandle('event_color');
if(!is_object($colorpicker) || !intval($colorpicker->getAttributeTypeID()) ) {
$colorpicker = AttributeType::add('event_color', t('Event Color Picker'), $pkg);
$eventmulti=CollectionAttributeKey::getByHandle('event_multidate');
if( !is_object($eventmulti) ) {
CollectionAttributeKey::add($multidateAttribute,
array('akHandle' => 'event_multidate',
'akName' => t('Event Dates'),
'akIsSearchable' => '1',
'akIsSearchableIndexed' => '1',
'akDateDisplayMode'=>'date_time_time'
),$pkg)->setAttributeSet($evset);
}
i have set attribute in this way but i got error during installation getcontroller on null
$eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$evset = $eaku->addSet('proevent', t('Pro Events'),$pkg);
$evsot = $eaku->addSet('proevent_additional_attributes', t('Pro Events Additional Attributes'),$pkg);
$euku = AttributeKeyCategory::getByHandle('user');
$euku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
$uset = $euku->addSet('user_set', t('Events Package'),$pkg);
$timen = AttributeType::getByHandle('times');
if($timen==NULL){
$timen = AttributeType::add('times','Time', $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('times'));
}
else if($timen->getAttributeTypeID()==NULL){
$timen = AttributeType::add('times','Time', $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('times'));
}
$multidateAttribute = AttributeType::getByHandle('multi_date');
if(!is_object($multidateAttribute) || !intval($multidateAttribute->getAttributeTypeID()) ) {
$multidateAttribute = AttributeType::add('multi_date', t('Multi Date'), $pkg);
$eaku->associateAttributeKeyType(AttributeType::getByHandle('multi_date'));
}
$colorpicker = AttributeType::getByHandle('event_color');
if(!is_object($colorpicker) || !intval($colorpicker->getAttributeTypeID()) ) {
$colorpicker = AttributeType::add('event_color', t('Event Color Picker'), $pkg);
$eventmulti=CollectionAttributeKey::getByHandle('event_multidate');
if( !is_object($eventmulti) ) {
CollectionAttributeKey::add($multidateAttribute,
array('akHandle' => 'event_multidate',
'akName' => t('Event Dates'),
'akIsSearchable' => '1',
'akIsSearchableIndexed' => '1',
'akDateDisplayMode'=>'date_time_time'
),$pkg)->setAttributeSet($evset);
}
i have set attribute in this way but i got error during installation getcontroller on null