Merge "Revert "ApiSandbox: Display params as JSON on request page""
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index 8390a0b..487d6f6 100644 (file)
@@ -296,7 +296,7 @@ abstract class HTMLFormField {
         * @param string|array $value The value the field was submitted with
         * @param array $alldata The data collected from the form
         *
-        * @return bool|string True on success, or String error to display, or
+        * @return bool|string|Message True on success, or String/Message error to display, or
         *   false to fail validation without displaying an error.
         */
        public function validate( $value, $alldata ) {
@@ -308,7 +308,7 @@ abstract class HTMLFormField {
                        && $this->mParams['required'] !== false
                        && $value === ''
                ) {
-                       return $this->msg( 'htmlform-required' )->parse();
+                       return $this->msg( 'htmlform-required' );
                }
 
                if ( isset( $this->mValidationCallback ) ) {
@@ -1034,7 +1034,7 @@ abstract class HTMLFormField {
         * with integer 0 as a value.
         *
         * @param array $array
-        * @return array
+        * @return array|string
         */
        public static function forceToStringRecursive( $array ) {
                if ( is_array( $array ) ) {
@@ -1194,4 +1194,19 @@ abstract class HTMLFormField {
        public function skipLoadData( $request ) {
                return !empty( $this->mParams['nodata'] );
        }
+
+       /**
+        * Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5
+        * form validation to work correctly.
+        *
+        * @return boolean
+        * @since 1.29
+        */
+       public function needsJSForHtml5FormValidation() {
+               if ( $this->mHideIf ) {
+                       // This is probably more restrictive than it needs to be, but better safe than sorry
+                       return true;
+               }
+               return false;
+       }
 }