Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/226946
Change subject: Allow HTMLTitleTextField to work on GET forms
......................................................................
Allow HTMLTitleTextField to work on GET forms
Just skip validation if it is a GET form and the current input is an
empty string. Callers will need to check that it is not the empty string
though.
Also make sure HTMLForm::mMethod is always lowercase.
Change-Id: I605f32048fe97eebd7e04b6ffd799759aeb7f31e
---
M includes/htmlform/HTMLForm.php
M includes/htmlform/HTMLTitleTextField.php
2 files changed, 11 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/46/226946/1
diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 48cc828..a56b398 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -1302,11 +1302,14 @@
* @return HTMLForm $this for chaining calls (since 1.20)
*/
public function setMethod( $method = 'post' ) {
- $this->mMethod = $method;
+ $this->mMethod = strtolower( $method );
return $this;
}
+ /**
+ * @return string Always lowercase
+ */
public function getMethod() {
return $this->mMethod;
}
diff --git a/includes/htmlform/HTMLTitleTextField.php
b/includes/htmlform/HTMLTitleTextField.php
index e1bc1a0..2124bb1 100644
--- a/includes/htmlform/HTMLTitleTextField.php
+++ b/includes/htmlform/HTMLTitleTextField.php
@@ -7,7 +7,8 @@
* Automatically does validation that the title is valid,
* as well as autocompletion if using the OOUI display format.
*
- * FIXME: Does not work for forms that support GET requests.
+ * Note: Forms using GET requests will need to make sure the title value is not
+ * an empty string.
*
* Optional parameters:
* 'namespace' - Namespace the page must be in
@@ -28,6 +29,11 @@
}
public function validate( $value, $alldata ) {
+ if ( $this->mParent->getMethod() === 'get' && $value === '' ) {
+ // If the form is a GET form and has no value, assume
it hasn't been
+ // submitted yet, and skip validation
+ return parent::validate( $value, $alldata );
+ }
try {
$title = Title::newFromTextThrow( $value );
} catch ( MalformedTitleException $e ) {
--
To view, visit https://gerrit.wikimedia.org/r/226946
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I605f32048fe97eebd7e04b6ffd799759aeb7f31e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits