Index: trunk/phase3/skins/common/shared.css |
— | — | @@ -123,6 +123,10 @@ |
124 | 124 | text-align: left !important; |
125 | 125 | } |
126 | 126 | |
| 127 | +.mw-htmlform-invalid-input td.mw-input input { |
| 128 | + border-color: red; |
| 129 | +} |
| 130 | + |
127 | 131 | input#wpSummary { |
128 | 132 | width: 80%; |
129 | 133 | } |
— | — | @@ -617,7 +621,7 @@ |
618 | 622 | .tipsy-arrow { |
619 | 623 | position: absolute; |
620 | 624 | /* @embed */ |
621 | | - background: url( 'images/tipsy-arrow.gif' ) no-repeat top left; |
| 625 | + background: url(images/tipsy-arrow.gif) no-repeat top left; |
622 | 626 | width: 13px; |
623 | 627 | height: 13px; |
624 | 628 | } |
Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -890,8 +890,10 @@ |
891 | 891 | |
892 | 892 | if ( $errors === true || ( !$wgRequest->wasPosted() && ( $this->mParent->getMethod() == 'post' ) ) ) { |
893 | 893 | $errors = ''; |
| 894 | + $errorClass = ''; |
894 | 895 | } else { |
895 | | - $errors = Html::rawElement( 'span', array( 'class' => 'error' ), $errors ); |
| 896 | + $errors = self::formatErrors( $errors ); |
| 897 | + $errorClass = 'mw-htmlform-invalid-input'; |
896 | 898 | } |
897 | 899 | |
898 | 900 | $label = $this->getLabelHtml( $cellAttributes ); |
— | — | @@ -903,15 +905,15 @@ |
904 | 906 | |
905 | 907 | $fieldType = get_class( $this ); |
906 | 908 | |
907 | | - if ($verticalLabel) { |
| 909 | + if ( $verticalLabel ) { |
908 | 910 | $html = Html::rawElement( 'tr', |
909 | 911 | array( 'class' => 'mw-htmlform-vertical-label' ), $label ); |
910 | 912 | $html .= Html::rawElement( 'tr', |
911 | | - array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ), |
| 913 | + array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass" ), |
912 | 914 | $field ); |
913 | 915 | } else { |
914 | 916 | $html = Html::rawElement( 'tr', |
915 | | - array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ), |
| 917 | + array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass} $errorClass" ), |
916 | 918 | $label . $field ); |
917 | 919 | } |
918 | 920 | |
— | — | @@ -1009,6 +1011,33 @@ |
1010 | 1012 | |
1011 | 1013 | return $flatOpts; |
1012 | 1014 | } |
| 1015 | + |
| 1016 | + /** |
| 1017 | + * @param $errors String|Message|Array of strings or Message instances |
| 1018 | + * @return String html |
| 1019 | + */ |
| 1020 | + protected static function formatErrors( $errors ) { |
| 1021 | + if ( is_array( $errors ) && count( $errors ) === 1 ) { |
| 1022 | + $errors = array_shift( $errors ); |
| 1023 | + } |
| 1024 | + |
| 1025 | + if ( is_array( $errors ) ) { |
| 1026 | + $lines = array(); |
| 1027 | + foreach ( $errors as $error ) { |
| 1028 | + if ( $error instanceof Message ) { |
| 1029 | + $lines[] = Html::rawElement( 'li', array(), $error->parse() ); |
| 1030 | + } else { |
| 1031 | + $lines[] = Html::rawElement( 'li', array(), $error ); |
| 1032 | + } |
| 1033 | + } |
| 1034 | + return Html::rawElement( 'ul', array( 'class' => 'error' ), implode( "\n", $lines ) ); |
| 1035 | + } else { |
| 1036 | + if ( $errors instanceof Message ) { |
| 1037 | + $errors = $errors->parse(); |
| 1038 | + } |
| 1039 | + return Html::rawElement( 'span', array( 'class' => 'error' ), $errors ); |
| 1040 | + } |
| 1041 | + } |
1013 | 1042 | } |
1014 | 1043 | |
1015 | 1044 | class HTMLTextField extends HTMLFormField { |