Implement HTMLTitleTextField with suggestions for non-OOUI forms, too
[lhc/web/wiklou.git] / includes / htmlform / HTMLTitleTextField.php
index 09fbaa7..410d15d 100644 (file)
@@ -80,4 +80,20 @@ class HTMLTitleTextField extends HTMLTextField {
                $params['relative'] = $this->mParams['relative'];
                return new TitleInputWidget( $params );
        }
+
+       public function getInputHtml( $value ) {
+               // add mw-searchInput class to enable search suggestions for non-OOUI, too
+               $this->mClass .= 'mw-searchInput';
+
+               // return the HTMLTextField html
+               return parent::getInputHtml( $value );
+       }
+
+       protected function getDataAttribs() {
+               return [
+                       'data-mw-searchsuggest' => FormatJson::encode( [
+                               'wrapAsLink' => false,
+                       ] ),
+               ];
+       }
 }