protected function _preSave($is_new) { parent::_preSave($is_new); if ($is_new) { $this->_generateKey(); if (array_key_exists($this->_key, self::getAll())) { throw new Exception(TBGContext::getI18n()->__('This field key already exists')); } } }