'check' => 'HTMLCheckField',
'toggle' => 'HTMLCheckField',
'int' => 'HTMLIntField',
+ 'float' => 'HTMLFloatField',
'info' => 'HTMLInfoField',
'selectorother' => 'HTMLSelectOrOtherField',
);
}
-class HTMLIntField extends HTMLTextField {
+class HTMLFloatField extends HTMLTextField {
function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
}
function validate( $value, $alldata ) {
$p = parent::validate( $value, $alldata );
- if( $p !== true ) return $p;
+ if ( $p !== true ) return $p;
- if ( intval( $value ) != $value ) {
- return wfMsgExt( 'htmlform-int-invalid', 'parse' );
+ if ( floatval( $value ) != $value ) {
+ return wfMsgExt( 'htmlform-float-invalid', 'parse' );
}
$in_range = true;
+ # The "int" part of these message names is rather confusing. They make
+ # equal sense for all numbers.
if ( isset( $this->mParams['min'] ) ) {
$min = $this->mParams['min'];
if ( $min > $value )
}
}
+class HTMLIntField extends HTMLFloatField {
+ function validate( $value, $alldata ) {
+ $p = parent::validate( $value, $alldata );
+
+ if ( $p !== true ) return $p;
+
+ if ( intval( $value ) != $value ) {
+ return wfMsgExt( 'htmlform-int-invalid', 'parse' );
+ }
+
+ return true;
+ }
+}
+
class HTMLCheckField extends HTMLFormField {
function getInputHTML( $value ) {
if ( !empty( $this->mParams['invert'] ) )