@@ -1972,6 +1972,45 @@ protected function _datetimeOptions($options) {
1972
1972
return $ options ;
1973
1973
}
1974
1974
1975
+ /**
1976
+ * Generate time inputs.
1977
+ *
1978
+ * ### Options:
1979
+ *
1980
+ * - `interval` The interval for the minutes select. Defaults to 1
1981
+ * - `empty` - If true, the empty select option is shown. If a string,
1982
+ * that string is displayed as the empty element.
1983
+ * - `round` - Set to `up` or `down` if you want to force rounding in either direction. Defaults to null.
1984
+ * - `value` | `default` The default value to be used by the input. A value in `$this->data`
1985
+ * matching the field name will override this value. If no default is provided `time()` will be used.
1986
+ * - `timeFormat` The time format to use, either 12 or 24.
1987
+ * - `second` Set to true to enable seconds drop down.
1988
+ *
1989
+ * To control the order of inputs, and any elements/content between the inputs you
1990
+ * can override the `dateWidget` template. By default the `dateWidget` template is:
1991
+ *
1992
+ * `{{month}}{{day}}{{year}}{{hour}}{{minute}}{{second}}{{meridian}}`
1993
+ *
1994
+ * @param string $fieldName Prefix name for the SELECT element
1995
+ * @param array $options Array of Options
1996
+ * @return string Generated set of select boxes for time formats chosen.
1997
+ */
1998
+ public function time ($ fieldName , $ options = []) {
1999
+ $ options += [
2000
+ 'empty ' => true ,
2001
+ 'value ' => null ,
2002
+ 'interval ' => 1 ,
2003
+ 'round ' => null ,
2004
+ 'timeFormat ' => 12 ,
2005
+ 'second ' => false ,
2006
+ ];
2007
+ $ options ['year ' ] = $ options ['month ' ] = $ options ['day ' ] = false ;
2008
+ $ options = $ this ->_initInputField ($ fieldName , $ options );
2009
+ $ options = $ this ->_datetimeOptions ($ options );
2010
+
2011
+ return $ this ->widget ('datetime ' , $ options );
2012
+ }
2013
+
1975
2014
/**
1976
2015
* Sets field defaults and adds field to form security input hash.
1977
2016
* Will also add the error class if the field contains validation errors.
0 commit comments