/** * Set the field value * * Method will set the field value, overriding the existing one * * @access public * @param mixed $value The default value to set * @param bool $setFromDB TRUE to specify that this value is from the DB, FALSE from the request. * Default is FALSE * @param bool $assignRealValue TRUE to filter out any values that is not in the options array, * FALSE to set as is. Default is TRUE */ public function setValue($value, $setFromDB=false, $assignRealValue=true) { if ($assignRealValue && !empty($this->extraInfo['options'])) { $index = Store_Array::searchCI($value, $this->extraInfo['options']); if ($index !== false) { $value = $this->extraInfo['options'][$index]; } else { $value = ''; } } parent::setValue($value, $setFromDB); }
/** * Check to see if the currency is supported * * Method will check to see if the currency $currency is supported * * @access protected * @param string $currency The currency string to check * @return bool TRUE if the currency is supported, FALSE if not */ protected function checkSupportedCurrencies($currency) { if (trim($currency) == '') { return false; } if (empty($this->supportedCurrencyCodes)) { return true; } return Store_Array::inArrayCI(trim($currency), $this->supportedCurrencyCodes); }
/** * Set the field value * * Method will set the field value, overriding the existing one * * @access public * @param mixed $value The default value to set * @param bool $setFromDB TRUE to specify that this value is from the DB, FALSE from the request. * Default is FALSE * @param bool $assignRealValue TRUE to filter out any values that is not in the options array, * FALSE to set as is. Default is TRUE */ public function setValue($value, $setFromDB=false, $assignRealValue=true) { if (!is_array($value)) { $value = array($value); $value = array_filter($value); } if ($assignRealValue && !empty($this->extraInfo['options'])) { $filtered = array(); foreach ($value as $key => $val) { $index = Store_Array::searchCI($val, $this->extraInfo['options']); if ($index !== false) { $filtered[$key] = $this->extraInfo['options'][$index]; } } $value = $filtered; } parent::setValue($value, $setFromDB); }