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
This commit is contained in:
parent
f734de5f7b
commit
06db921d75
1 changed files with 2 additions and 2 deletions
|
|
@ -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' );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue