* params) or strings (message keys)
*/
function trySubmit() {
+ $valid = true;
+ $hoistedErrors = array();
+ $hoistedErrors[] = isset( $this->mValidationErrorMessage )
+ ? $this->mValidationErrorMessage
+ : array( 'htmlform-invalid-input' );
+
$this->mWasSubmitted = true;
# Check for cancelled submission
if ( $field->isHidden( $this->mFieldData ) ) {
continue;
}
- if ( $field->validate(
- $this->mFieldData[$fieldname],
- $this->mFieldData )
- !== true
- ) {
- return isset( $this->mValidationErrorMessage )
- ? $this->mValidationErrorMessage
- : array( 'htmlform-invalid-input' );
+ $res = $field->validate( $this->mFieldData[$fieldname], $this->mFieldData );
+ if ( $res !== true ) {
+ $valid = false;
+ if ( $res !== false && !$field->canDisplayErrors() ) {
+ $hoistedErrors[] = array( 'rawmessage', $res );
+ }
+ }
+ }
+
+ if ( !$valid ) {
+ if ( count( $hoistedErrors ) === 1 ) {
+ $hoistedErrors = $hoistedErrors[0];
}
+ return $hoistedErrors;
}
$callback = $this->mSubmitCallback;
return false;
}
+ /**
+ * True if this field type is able to display errors; false if validation errors need to be
+ * displayed in the main HTMLForm error area.
+ * @return bool
+ */
+ public function canDisplayErrors() {
+ return true;
+ }
+
/**
* Get a translated interface message
*
public function getInputHTML( $value ) {
return '';
}
+
+ public function canDisplayErrors() {
+ return false;
+ }
}
"htmlform-title-not-exists": "[[:$1]] does not exist.",
"htmlform-user-not-exists": "<strong>$1</strong> does not exist.",
"htmlform-user-not-valid": "<strong>$1</strong> isn't a valid username.",
+ "rawmessage": "$1",
"sqlite-has-fts": "$1 with full-text search support",
"sqlite-no-fts": "$1 without full-text search support",
"logentry-delete-delete": "$1 {{GENDER:$2|deleted}} page $3",
"htmlform-title-not-exists": "Error message shown if the page title provided by the user does not exist. $1 is the page title.",
"htmlform-user-not-exists": "Error message shown if a user with the name provided by the user does not exist. $1 is the username.",
"htmlform-user-not-valid": "Error message shown if the name provided by the user isn't a valid username. $1 is the username.",
+ "rawmessage": "{{notranslate}} Used to pass arbitrary text as a message specifier array",
"sqlite-has-fts": "Shown on [[Special:Version]].\nParameters:\n* $1 - version",
"sqlite-no-fts": "Shown on [[Special:Version]].\nParameters:\n* $1 - version",
"logentry-delete-delete": "{{Logentry|[[Special:Log/delete]]}}",