Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
teraßyte Posted December 4, 2022 Posted December 4, 2022 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. Afrodude 1
ReyDev Posted December 4, 2022 Posted December 4, 2022 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' ) ) );
teraßyte Posted December 4, 2022 Author Posted December 4, 2022 (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 December 4, 2022 by teraßyte
Recommended Posts