OOUIHTMLForm: Make setting 'readonly' on a text field actually work
authorKunal Mehta <legoktm@gmail.com>
Tue, 30 Jun 2015 20:03:58 +0000 (13:03 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 30 Jun 2015 20:03:58 +0000 (13:03 -0700)
Previously 'readOnly' was set to an empty string, which casts to boolean
false.

Change-Id: I7d1e7f02731c7235da2ae1e0a5e3d0be2b44d978

includes/htmlform/HTMLTextField.php

index 9c5b868..5c04ee2 100644 (file)
@@ -113,6 +113,11 @@ class HTMLTextField extends HTMLFormField {
                        'tabindex' => 'tabIndex',
                ) );
 
+               if ( isset( $attribs['readOnly'] ) ) {
+                       // This needs to be set to a boolean value
+                       $attribs['readOnly'] = true;
+               }
+
                $type = $this->getType( $attribs );
 
                return new OOUI\TextInputWidget( array(