/** * Validate input and set value * @param mixed * @return mixed */ public function validator($varInput) { try { $varInput = Number::create($varInput)->getAmount(); } catch (\InvalidArgumentException $e) { $this->addError($GLOBALS['TL_LANG']['ERR']['numberInputNotAllowed']); } return parent::validator($varInput); }
/** * @param mixed $varInput * @return mixed */ protected function validator($varInput) { // Get language id $intId = $this->activeRecord ? $this->activeRecord->{$this->strName} : $GLOBALS['TL_CONFIG'][$this->strName]; // Check if translation fields should not be empty saved if (!$GLOBALS['TL_CONFIG']['dontfillEmptyTranslationFields']) { // Fill all empty fields with the content of the fallback field $varInput = \TranslationFieldsWidgetHelper::addFallbackValueToEmptyField($varInput); parent::validator($varInput); } else { // Check only the first field parent::validator($varInput[key($varInput)]); } // Check if array if (is_array($varInput)) { if (!parent::hasErrors()) { // Save values and return fid return \TranslationFieldsWidgetHelper::saveValuesAndReturnFid($varInput, $intId); } } return $intId; }