teraßyte Posted December 6 Posted December 6 Here's some quick test code to check the issue: $form = new \IPS\Helpers\Form; $form->add( new \IPS\Helpers\Form\Checkbox( 'example_checkbox', NULL, TRUE ) ); if ( $values = $form->values() ) { var_dump( $values );exit; } The code will always output either FALSE or TRUE, but it will never throw an error telling you you must select the checkbox. This happens because of the validate function in \IPS\Helpers\Form\FormAbstract: /** * Validate * * @throws \InvalidArgumentException * @return TRUE */ public function validate() { if( ( $this->value === '' OR ( \is_array( $this->value ) AND empty( $this->value ) ) ) and $this->required ) { throw new \InvalidArgumentException('form_required'); } [...] At this point, the variable $this->value contains either TRUE or FALSE and fails the empty string check with 3 equal signs. The empty() check is skipped too because the value is not an array. === The same issue is also present in v5 Beta 6. Adriano Faria and SeNioR- 2
Marc Posted December 6 Posted December 6 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release.
Recommended Posts