HTMLDateTimeField: Fix 'placeholder' attribute handling
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 24 Nov 2016 15:13:40 +0000 (16:13 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 24 Nov 2016 15:13:40 +0000 (16:13 +0100)
Parent class HTMLTextField handles this specially and we have to match it.

Change-Id: Ibff3caba2a58c2bcbfb342789aae9f0939b7687f

includes/htmlform/fields/HTMLDateTimeField.php

index 88dcd24..a0eb58f 100644 (file)
@@ -36,6 +36,11 @@ class HTMLDateTimeField extends HTMLTextField {
                        throw new InvalidArgumentException( "Invalid type '$this->mType'" );
                }
 
+               if ( $this->mPlaceholder === '' ) {
+                       // Messages: htmlform-date-placeholder htmlform-time-placeholder htmlform-datetime-placeholder
+                       $this->mPlaceholder = $this->msg( "htmlform-{$this->mType}-placeholder" )->text();
+               }
+
                $this->mClass .= ' mw-htmlform-datetime-field';
        }
 
@@ -43,11 +48,6 @@ class HTMLDateTimeField extends HTMLTextField {
                $parentList = array_diff( $list, [ 'min', 'max' ] );
                $ret = parent::getAttributes( $parentList );
 
-               if ( in_array( 'placeholder', $list ) && !isset( $ret['placeholder'] ) ) {
-                       // Messages: htmlform-date-placeholder htmlform-time-placeholder htmlform-datetime-placeholder
-                       $ret['placeholder'] = $this->msg( "htmlform-{$this->mType}-placeholder" )->text();
-               }
-
                if ( in_array( 'min', $list ) && isset( $this->mParams['min'] ) ) {
                        $min = $this->parseDate( $this->mParams['min'] );
                        if ( $min ) {