Index: branches/5.2.x/units/listing_types/listing_types_event_handler.php =================================================================== diff -u -N -r14254 -r14595 --- branches/5.2.x/units/listing_types/listing_types_event_handler.php (.../listing_types_event_handler.php) (revision 14254) +++ branches/5.2.x/units/listing_types/listing_types_event_handler.php (.../listing_types_event_handler.php) (revision 14595) @@ -1,6 +1,6 @@ Application->SetVar($event->getPrefixSpecial(true).'_id', $object->GetID()); } - function OnPreSave(&$event) - { - $object =& $event->getObject(); - $item_info = $this->Application->GetVar($event->Prefix); - if(is_array($item_info)) - { - $item_info = array_shift($item_info); - if( getArrayValue($item_info, 'EnableBuying') ) - { - $options = $object->GetFieldOptions('ShopCartName'); - $options['required'] = 1; - $object->SetFieldOptions('ShopCartName', $options); - } - } - parent::OnPreSave($event); - } - function OnEdit(&$event) { if ($this->Application->prefixRegistred('p')) { $this->Application->recallObject('p', null, Array('skip_autoload' => true)); } parent::OnEdit($event); } + + /** + * Makes shopping cart name required, when buying is enabled + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeItemUpdate(&$event) + { + parent::OnBeforeItemUpdate($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $object->setRequired('ShopCartName', $object->GetDBField('EnableBuying')); + } } \ No newline at end of file