Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -184,15 +184,9 @@ class _Number extends FormAbstract
|
||||
do the thousand seperator in case what we received was the former alredy, which would turn
|
||||
for example "10,00" into "1000" */
|
||||
$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' );
|
||||
}
|
||||
|
||||
|
||||
/* Convert to int/float */
|
||||
if ( $this->options['decimals'] )
|
||||
if ( $this->options['decimals'] and $value != '' )
|
||||
{
|
||||
$value = \floatval( $value );
|
||||
if ( \is_int( $this->options['decimals'] ) )
|
||||
@@ -202,7 +196,7 @@ class _Number extends FormAbstract
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = \intval( $value );
|
||||
$value = ( $value != '' ) ? \intval( $value ) : '';
|
||||
}
|
||||
|
||||
/* Return */
|
||||
@@ -216,16 +210,22 @@ class _Number extends FormAbstract
|
||||
* @return TRUE
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
{
|
||||
parent::validate();
|
||||
|
||||
if ( $this->options['unlimited'] === NULL or $this->value !== $this->options['unlimited'] )
|
||||
{
|
||||
if ( $this->options['min'] !== NULL and $this->value < $this->options['min'] )
|
||||
{
|
||||
/* If it's not numeric, throw an exception */
|
||||
if ( ( !\is_numeric( $this->value ) and $this->value !== '' and $this->required === FALSE ) or ( !\is_numeric( $this->value ) and $this->required === TRUE ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( 'form_number_bad' );
|
||||
}
|
||||
|
||||
if ( $this->options['min'] !== NULL and (int) $this->value < $this->options['min'] )
|
||||
{
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_number_min', FALSE, array( 'sprintf' => array( $this->options['min'] ) ) ) );
|
||||
}
|
||||
if ( $this->options['max'] !== NULL and $this->value > $this->options['max'] )
|
||||
if ( $this->options['max'] !== NULL and (int) $this->value > $this->options['max'] )
|
||||
{
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_number_max', FALSE, array( 'sprintf' => array( $this->options['max'] ) ) ) );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user