From: jeroendedauw Date: Sat, 11 Aug 2012 22:23:46 +0000 (+0200) Subject: Improve handling of the required argument in HTMLForm field definitions X-Git-Tag: 1.31.0-rc.0~22765^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=06db921d75e455d0391340dbba0ff9c0a9b60139;p=lhc%2Fweb%2Fwiklou.git Improve handling of the required argument in HTMLForm field definitions array( 'required' => false ) will now result in the field not being required rather then the unexpected opossite. And this is now possible (without doing some extra if) array( 'required' => getSomeBoolean() ) Change-Id: I1fc22b16ab1fa17111c48aa664aaf47de5f7075a --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index ce9c3772c7..e617f17516 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1109,7 +1109,7 @@ abstract class HTMLFormField { * @return Mixed Bool true on success, or String error to display. */ function validate( $value, $alldata ) { - if ( isset( $this->mParams['required'] ) && $value === '' ) { + if ( isset( $this->mParams['required'] ) && $this->mParams['required'] !== false && $value === '' ) { return wfMsgExt( 'htmlform-required', 'parseinline' ); } @@ -2153,7 +2153,7 @@ class HTMLSelectAndOtherField extends HTMLSelectField { return $p; } - if ( isset( $this->mParams['required'] ) && $value[1] === '' ) { + if ( isset( $this->mParams['required'] ) && $this->mParams['required'] !== false && $value[1] === '' ) { return wfMsgExt( 'htmlform-required', 'parseinline' ); }