Jump to content

[BUG 4.7.5] Wrong error text for Helper Form Number field when using a minimum value


Recommended Posts

Posted

Create a simple form with a number field with a minimum number required and an unlimited option with a 0 value:

$form = new \IPS\Helpers\Form;

$form->add( new \IPS\Helpers\Form\Number( 'test', 0, FALSE, array( 'min' => 2, 'unlimited' => 0, 'unlimitedLang' => 'disabled' ) ) );

 

Now load the form, uncheck the Disabled checkbox, and submit the form. Once you've done all the steps this is the error that appears right under the number field:

Quote

The value must be larger than 2.

 

The error makes you believe you have to insert at least 3 but the field does indeed accept a 2 value. The correct error should instead be:

Quote

The value must be at least 2.

Posted
7 hours ago, teraßyte said:
$form->add( new \IPS\Helpers\Form\Number( 'test', 0, FALSE, array( 'min' => 2, 'unlimited' => 0, 'unlimitedLang' => 'disabled' ) ) );

 

change the default value to `2` instead of `0`(second parameter) and try.
 

$form->add( new \IPS\Helpers\Form\Number( 'test', 2, FALSE, array( 'min' => 2, 'unlimited' => 0, 'unlimitedLang' => 'disabled' ) ) );


 

Posted (edited)

The default value is 0 because I need that field to be disabled by default. 🙂

 

The real issue is the error string being worded wrong.

The PHP code check is >= 2 but the error only mentions > 2.

Edited by teraßyte
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...