From 06db921d75e455d0391340dbba0ff9c0a9b60139 Mon Sep 17 00:00:00 2001 From: jeroendedauw Date: Sun, 12 Aug 2012 00:23:46 +0200 Subject: [PATCH] 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 --- includes/HTMLForm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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' ); } -- 2.20.1