public function setId($id) { // Cache the old JS object name if possible if ($this->getData('id') !== null) { $oldJsObjectName = $this->getJsObjectName(); } // replace . : - with _ $id = $id ? str_replace(['.', ':', '-'], '_', $id) : $id; parent::setId($id); // Swap the old JS object name for the new JS object name if ($this->getData('id') !== null && isset($oldJsObjectName)) { $newJsObjectName = $this->getJsObjectName(); if ($newJsObjectName !== $oldJsObjectName) { foreach ($this->getChild() as $child) { /** @var Mage_Core_Block_Abstract $child */ if ($child instanceof Mage_Adminhtml_Block_Widget_Button && $child->getOnclick()) { $onclick = $child->getOnclick(); $onclick = str_replace($oldJsObjectName, $newJsObjectName, $onclick); $child->setOnclick($onclick); } } } } return $this; }