コード例 #1
0
ファイル: NumberInput.php プロジェクト: stoo2000/membermap
 public function formatValue()
 {
     if (in_array($this->htmlId, array('marker_lat', 'marker_lon'))) {
         $value = $this->value;
         $value = floatval($value);
         $value = round($value, 6);
         /* Convert decimal point and thousand separators to a way PHP understand */
         $value = str_replace(trim(\IPS\Member::loggedIn()->language()->locale['thousands_sep']), '', $value);
         $value = str_replace(trim(\IPS\Member::loggedIn()->language()->locale['decimal_point']), '.', $value);
         /* If it's not numeric, throw an exception */
         if (!is_numeric($value) and $value !== '' and $this->required === FALSE or !is_numeric($value) and $this->required === TRUE) {
             throw new \InvalidArgumentException('form_number_bad');
         }
         return $value;
     } else {
         return parent::formatValue();
     }
 }