当前位置: 首页>>代码示例>>PHP>>正文


PHP FormHelper::dateTime方法代码示例

本文整理汇总了PHP中FormHelper::dateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP FormHelper::dateTime方法的具体用法?PHP FormHelper::dateTime怎么用?PHP FormHelper::dateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormHelper的用法示例。


在下文中一共展示了FormHelper::dateTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dateYMD

 function dateYMD($fieldName, $selected = null, $attributes = array(), $showEmpty = true)
 {
     if (!isset($this->options['month'])) {
         $this->options['month'] = array();
         for ($i = 1; $i <= 12; $i++) {
             $this->options['month'][sprintf("%02d", $i)] = $i;
         }
     }
     $sep = array('', '', '');
     if (isset($attributes['separator'])) {
         if (is_array($attributes['separator'])) {
             $sep = $attributes['separator'];
             $attributes['separator'] = "";
         }
     } else {
         $attributes['separator'] = "";
         $sep = array("年", "月", "日");
     }
     $ret = parent::dateTime($fieldName, 'YMD', 'NONE', $selected, $attributes, $showEmpty);
     $ret = preg_replace('|</select>|', '{/select}' . @$sep[0], $ret, 1);
     $ret = preg_replace('|</select>|', '{/select}' . @$sep[1], $ret, 1);
     $ret = preg_replace('|</select>|', '{/select}' . @$sep[2], $ret, 1);
     $ret = $ret = str_replace('{/select}', '</select>', $ret);
     return $ret;
 }
开发者ID:09jz0138,项目名称:skit,代码行数:25,代码来源:exform.php

示例2: dateTime

 /**
  * Calls ParsleyProcessor::processDatetimeInput() to apply data-parsley-multiple on date inputs
  *
  * @param string $fieldName
  * @param string $dateFormat
  * @param string $timeFormat
  * @param array $attributes
  * @return string
  */
 public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $attributes = array())
 {
     if (isset($this->_processor)) {
         $attributes = $this->_processor->processDatetimeInput($fieldName, $attributes);
     }
     return parent::dateTime($fieldName, $dateFormat, $timeFormat, $attributes);
 }
开发者ID:codaxis,项目名称:cakephp-parsley-helper,代码行数:16,代码来源:ParsleyFormHelper.php

示例3: dateTime

    /**
     * dateTime method
     *
     * Use an input and the jquery ui datepicker instead
     *
     * Pass $options['selects'] = true to bypass this override
     *
     * @param mixed $fieldName
     * @param string $dateFormat 'DMY'
     * @param string $timeFormat '12'
     * @param mixed $selected null
     * @param array $options array()
     * @param bool $showEmpty true
     * @return void
     * @access public
     */
    public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected = null, $options = array(), $showEmpty = true)
    {
        if (!empty($options['selects'])) {
            unset($options['selects']);
            return parent::dateTime($fieldName, $dateFormat, $timeFormat, $selected, $options, $showEmpty);
        }
        $options = $this->_initInputField($fieldName, array_merge(array('type' => 'text'), $options));
        $id = $options['id'];
        if (isset($this->Asset)) {
            $this->Asset->css('/js/theme/ui.datepicker', null, null, $this->name);
            $this->Asset->js('jquery-ui', $this->name);
            $timeSuffix = '';
            if ($timeFormat) {
                $time = array_pop(explode(' ', $options['value']));
                if ($time) {
                    preg_match('@[1-9]@', $time, $matches);
                    if ($matches) {
                        $timeSuffix = ' ' . $time;
                    }
                }
            }
            if (!empty($options['value'])) {
                if ($timeSuffix) {
                    $options['value'] = str_replace('-', '/', $options['value']);
                } else {
                    list($options['value']) = str_replace('-', '/', explode(' ', $options['value']));
                }
            }
            $dateFormat = 'yy/mm/dd' . $timeSuffix;
            $this->Asset->codeBlock('$(document).ready(function() {
					$("#' . $id . '")
						.datepicker({
							showOn: \'button\',
							buttonImage: \'' . $this->Html->url('/img/calendar.gif') . '\',
							buttonImageOnly: true,
							dateFormat: \'' . $dateFormat . '\'
						});
				});', array('inline' => false));
        }
        return $this->text($fieldName, am($options, array('class' => 'datepicker')));
    }
开发者ID:hiromi2424,项目名称:mi,代码行数:57,代码来源:mi_form.php

示例4: dateTime

 /**
  * 「年月日時分」入力セレクトボックス作成機能を拡張する
  */
 public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $attributes = array())
 {
     if (isset($attributes['extraFormat'])) {
         $this->_extraFormat[$fieldName] = $attributes['extraFormat'];
         unset($attributes['extraFormat']);
     }
     return parent::dateTime($fieldName, $dateFormat, $timeFormat, $attributes);
 }
开发者ID:Shiro-Nwal,项目名称:sin-kaisha-khine,代码行数:11,代码来源:ExtFormHelper.php

示例5: dateTime

 /**
  * @deprecated
  * use Form::dateTimeExt
  */
 public function dateTime($field, $options = array(), $tf = 24, $s = null, $a = array())
 {
     # temp fix
     if (!is_array($options)) {
         if ($options === null) {
             $options = 'DMY';
         }
         return parent::dateTime($field, $options, $tf, $s, $a);
     }
     return $this->dateTimeExt($field, $options);
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:15,代码来源:FormExtHelper.php

示例6: dateTime

 public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $attributes = array())
 {
     return parent::dateTime($fieldName, $dateFormat, $timeFormat, $attributes);
 }
开发者ID:KamiMoon,项目名称:volunteeromaha,代码行数:4,代码来源:Bootstrap3FormHelper.php

示例7: dateTime

 /**
  * Custom fix to overwrite the default of non iso 12 hours to 24 hours.
  * Try to use Form::dateTimeExt, though.
  *
  * @see https://cakephp.lighthouseapp.com/projects/42648/tickets/3945-form-helper-should-use-24-hour-format-as-default-iso-8601
  *
  * @param string $field
  * @param mixed $options
  * @return string Generated set of select boxes for the date and time formats chosen.
  */
 public function dateTime($field, $options = array(), $timeFormat = 24, $attributes = array())
 {
     // temp fix
     if (!is_array($options)) {
         return parent::dateTime($field, $options, $timeFormat, $attributes);
     }
     return $this->dateTimeExt($field, $options);
 }
开发者ID:miznokruge,项目名称:base-cake,代码行数:18,代码来源:FormExtHelper.php

示例8: dateTime

 function dateTime($fieldName, $dateFormat = 'YMD', $timeFormat = 24, $selected = null, $attributes = array())
 {
     if (empty($attributes)) {
         $attributes['separator'] = array();
     }
     $attributes += array('empty' => false);
     $separator = '-';
     if (isset($attributes['separator'])) {
         $separator = $attributes['separator'];
         $attributes['separator'] = '-';
     }
     if (!isset($attributes['monthNames'])) {
         $attributes['monthNames'] = false;
     }
     $date = parent::dateTime($fieldName, $dateFormat, null, $selected, $attributes);
     $time = parent::dateTime($fieldName, null, $timeFormat, $selected, $attributes);
     if (is_array($separator)) {
         $defaults = array('year' => __('年', true), 'month' => __('月', true), 'day' => __('日', true), 'hour' => __('時', true), 'minute' => __('分', true), 'second' => __('秒', true));
         $separator = array_merge($defaults, $separator);
         $format = array();
         if ($dateFormat != 'NONE' && !empty($dateFormat)) {
             foreach (preg_split('//', $dateFormat, -1, PREG_SPLIT_NO_EMPTY) as $char) {
                 switch ($char) {
                     case 'Y':
                         $format[] = $separator['year'];
                         break;
                     case 'M':
                         $format[] = $separator['month'];
                         break;
                     case 'D':
                         $format[] = $separator['day'];
                         break;
                 }
             }
         }
         preg_match_all('|<select.*?>.+?</select>|ms', $date, $matches);
         $date = "";
         for ($i = 0; $i < count($matches[0]); $i++) {
             $date .= $matches[0][$i] . $format[$i];
         }
         $format = array();
         if ($timeFormat != 'NONE' && !empty($timeFormat)) {
             switch ($timeFormat) {
                 case 12:
                     $format[] = $separator['hour'];
                     $format[] = $separator['minute'];
                     $format[] = '';
                 case 24:
                     $format[] = $separator['hour'];
                     $format[] = $separator['minute'];
                     break;
                 default:
                     break;
             }
         }
         preg_match_all('|<select.*?>.+?</select>|ms', $time, $matches);
         $time = "";
         for ($i = 0; $i < count($matches[0]); $i++) {
             $time .= $matches[0][$i] . $format[$i];
         }
     } elseif (is_string($separator)) {
         $date = str_replace('</select>-', '</select>' . $separator, $date);
     }
     return $date . $time;
 }
开发者ID:hiromi2424,项目名称:cake_base,代码行数:65,代码来源:jp_form.php


注:本文中的FormHelper::dateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。