Permalink
Browse files

Merge pull request #2103 from phpnode/1948-fix-html5-input-types

#1948 tidy up html5 input types
  • Loading branch information...
2 parents 887faeb + ba7b7c4 commit 6d3abf100b52ecebe1926fe9a619b23d234922b6 @samdark samdark committed Feb 12, 2013
Showing with 194 additions and 2 deletions.
  1. +1 −0 CHANGELOG
  2. +159 −0 framework/web/helpers/CHtml.php
  3. +34 −2 framework/web/widgets/CActiveForm.php
View
@@ -19,6 +19,7 @@ Version 1.1.14 work in progress
- Bug #2086: Fixed .hgignore rule for assets folder (GeXu3, Koduc)
- Enh: Better CFileLogRoute performance (Qiang, samdark)
- Enh #1847: Added COutputCache::varyByLanguage to generate separate cache for different languages (Obramko)
+- Enh #1948: Tidy up and improve html5 input support in CHtml and CActiveForm (phpnode)
- Enh #1977: CFormatter::normalizeDateValue() now is protected instead of private to enable child classes to override it (etienneq)
- Enh #2038: CFormatter::formatNtext() method can replace newlines with `<p></p>` not just with `<br />` as it was before (resurtm)
- Chg #645: CDbConnection now throws CDbException when failed to open DB connection instead of failing with a warning (kidol, eirikhm, samdark, cebe)
@@ -581,6 +581,125 @@ public static function textField($name,$value='',$htmlOptions=array())
}
/**
+ * Generates a number field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function numberField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('number',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates a range field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function rangeField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('range',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates a date field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function dateField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('date',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates a time field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function timeField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('time',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates an email field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function emailField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('email',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates a telephone field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function telField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('tel',$name,$value,$htmlOptions);
+ }
+
+ /**
+ * Generates a URL field input.
+ * @param string $name the input name
+ * @param string $value the input value
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see inputField
+ * @since 1.1.14
+ */
+ public static function urlField($name,$value='',$htmlOptions=array())
+ {
+ self::clientChange('change',$htmlOptions);
+ return self::inputField('url',$name,$value,$htmlOptions);
+ }
+
+ /**
* Generates a hidden input.
* @param string $name the input name
* @param string $value the input value
@@ -1357,6 +1476,46 @@ public static function activeDateField($model,$attribute,$htmlOptions=array())
return self::activeInputField('date',$model,$attribute,$htmlOptions);
}
+ /**
+ * Generates a time field input for a model attribute.
+ * If the attribute has input error, the input field's CSS class will
+ * be appended with {@link errorCss}.
+ * @param CModel $model the data model
+ * @param string $attribute the attribute
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see activeInputField
+ * @since 1.1.14
+ */
+ public static function activeTimeField($model,$attribute,$htmlOptions=array())
+ {
+ self::resolveNameID($model,$attribute,$htmlOptions);
+ self::clientChange('change',$htmlOptions);
+ return self::activeInputField('time',$model,$attribute,$htmlOptions);
+ }
+
+ /**
+ * Generates a telephone field input for a model attribute.
+ * If the attribute has input error, the input field's CSS class will
+ * be appended with {@link errorCss}.
+ * @param CModel $model the data model
+ * @param string $attribute the attribute
+ * @param array $htmlOptions additional HTML attributes. Besides normal HTML attributes, a few special
+ * attributes are also recognized (see {@link clientChange} and {@link tag} for more details.)
+ * @return string the generated input field
+ * @see clientChange
+ * @see activeInputField
+ * @since 1.1.14
+ */
+ public static function activeTelField($model,$attribute,$htmlOptions=array())
+ {
+ self::resolveNameID($model,$attribute,$htmlOptions);
+ self::clientChange('change',$htmlOptions);
+ return self::activeInputField('time',$model,$attribute,$htmlOptions);
+ }
+
/**
* Generates a hidden input for a model attribute.
@@ -264,7 +264,7 @@ class CActiveForm extends CWidget
* ......
* }
* </pre>
- */
+ */
public $enableAjaxValidation=false;
/**
* @var boolean whether to enable client-side data validation. Defaults to false.
@@ -645,6 +645,38 @@ public function dateField($model,$attribute,$htmlOptions=array())
return CHtml::activeDateField($model,$attribute,$htmlOptions);
}
+
+ /**
+ * Renders a time field for a model attribute.
+ * This method is a wrapper of {@link CHtml::activeTimeField}.
+ * Please check {@link CHtml::activeTimeField} for detailed information
+ * about the parameters for this method.
+ * @param CModel $model the data model
+ * @param string $attribute the attribute
+ * @param array $htmlOptions additional HTML attributes.
+ * @return string the generated input field
+ * @since 1.1.14
+ */
+ public function timeField($model,$attribute,$htmlOptions=array())
+ {
+ return CHtml::activeTimeField($model,$attribute,$htmlOptions);
+ }
+
+ /**
+ * Renders a time field for a model attribute.
+ * This method is a wrapper of {@link CHtml::activeTimeField}.
+ * Please check {@link CHtml::activeTimeField} for detailed information
+ * about the parameters for this method.
+ * @param CModel $model the data model
+ * @param string $attribute the attribute
+ * @param array $htmlOptions additional HTML attributes.
+ * @return string the generated input field
+ * @since 1.1.14
+ */
+ public function telField($model,$attribute,$htmlOptions=array())
+ {
+ return CHtml::activeTimeField($model,$attribute,$htmlOptions);
+ }
/**
* Renders a text field for a model attribute.
* This method is a wrapper of {@link CHtml::activeTextField}.
@@ -869,4 +901,4 @@ public static function validateTabular($models, $attributes=null, $loadInput=tru
}
return function_exists('json_encode') ? json_encode($result) : CJSON::encode($result);
}
-}
+}

0 comments on commit 6d3abf1

Please sign in to comment.