/** * Before saving the config data, update path * Also decide whether to encrypt value * * @return $this */ protected function _beforeSave() { if ((string) $this->getValue()) { $this->_updatePath(); return parent::_beforeSave(); } return $this; }
/** * Prepare data before save * * If field does not have value and method is enabled throw exception */ protected function _beforeSave() { if (!$this->getValue() && $this->isValueChanged()) { $data = $this->getData(); foreach ($this->_activeField as $field) { $fieldData = $data['groups']['braintree']['fields'][$field]; if (isset($fieldData['value']) && $fieldData['value'] || isset($fieldData['inherit']) && $fieldData['inherit'] && (string) Mage::getConfig()->getNode('default/payment/braintree/' . $field)) { if (strpos($field, 'paypal') !== false) { $methodName = 'PayPal'; } else { $methodName = 'Credit Card'; } Mage::throwException(Mage::helper('braintree_payments')->__('The following fields are required to be completed to save the configuration: ' . 'Merchant ID, Merchant Account ID, Public Key and Private Key. No changes were saved')); } } } parent::_beforeSave(); }