* @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;
}
return "$select<br />\n$textbox";
}
+ function getInputOOUI( $value ) {
+ return false;
+ }
+
/**
* @param WebRequest $request
*
return "$select<br />\n$textbox";
}
+ function getInputOOUI( $value ) {
+ return false;
+ }
+
/**
* @param WebRequest $request
*
* 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
}
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 {
if ( !$this->mParams['relative'] ) {
$title = Title::newFromTextThrow( $value );
// No form input yet
return true;
}
- try {
- $titleObj = Title::newFromTextThrow( $title );
- } catch ( MalformedTitleException $e ) {
- $msg = $this->msg( $e->getErrorMessage() );
- $params = $e->getErrorMessageParameters();
- if ( $params ) {
- $msg->params( $params );
- }
- return $msg->parse();
- }
- if ( !$titleObj->canExist() ) {
- return $this->msg(
- 'changecontentmodel-title-cantexist',
- $titleObj->getPrefixedText()
- )->escaped();
- }
+
+ // Already validated by HTMLForm, but if not, throw
+ // and exception instead of a fatal
+ $titleObj = Title::newFromTextThrow( $title );
$this->oldRevision = Revision::newFromTitle( $titleObj ) ?: false;
$that = $this;
$fields = array(
'pagetitle' => array(
- 'type' => 'text',
+ 'type' => 'title',
+ 'creatable' => true,
'name' => 'pagetitle',
'default' => $this->par,
'label-message' => 'changecontentmodel-title-label',
"changecontentmodel-success-title": "The content model was changed",
"changecontentmodel-success-text": "The content type of [[:$1]] has been changed.",
"changecontentmodel-cannot-convert": "The content on [[:$1]] cannot be converted to a type of $2.",
- "changecontentmodel-title-cantexist": "It is not possible to have a page at $1.",
"changecontentmodel-nodirectediting": "The $1 content model does not support direct editing",
"log-name-contentmodel": "Content model change log",
"log-description-contentmodel": "Events related to the content models of a page",
"changecontentmodel-success-title": "Title of the success page of the change content model special page",
"changecontentmodel-success-text": "Message telling user that their change has been successfully done.\n* $1 - Target page title",
"changecontentmodel-cannot-convert": "Error message shown if the content model cannot be changed to the specified type. $1 is the page title, $2 is the localized content model name.",
- "changecontentmodel-title-cantexist": "Error message shown if the page the user provided is a special page.\n\nParameters:\n* $1 - the page title which cannot exist",
"changecontentmodel-nodirectediting": "Error message shown if the content model does not allow for direct editing. $1 is the localized name of the content model.",
"log-name-contentmodel": "{{doc-logpage}}\n\nTitle of [[Special:Log/contentmodel]].",
"log-description-contentmodel": "Text in [[Special:Log/contentmodel]].",