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


PHP sfWidgetForm::generateTwoCharsRange方法代码示例

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


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

示例1: configure

 /**
  * Constructor.
  *
  * Available options:
  *
  *  * format:                 The time format string (%hour%:%minute%)
  *  * hours:                  An array of hours for the hour select tag (optional)
  *  * minutes:                An array of minutes for the minute select tag (optional)
  *  * can_be_empty:           Whether the widget accept an empty value (true by default)
  *  * empty_value:            String to use as empty value
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('format', '%hour%:%minute%');
     $this->addOption('hours', parent::generateTwoCharsRange(0, 23));
     $this->addOption('minutes', array('00', '15', '30', '45'));
     $this->addOption('can_be_empty', true);
     $this->addOption('empty_value', '');
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:24,代码来源:ohrmWidgetTimeDropDown.php

示例2: configure

 /**
  * Configures the current widget.
  *
  * The attributes are passed to both the date and the time widget.
  *
  * If you want to pass HTML attributes to one of the two widget, pass an
  * attributes option to the date or time option (see below).
  *
  * Available options:
  *
  *  * format_date: The format string in js and php for date. (see http://docs.jquery.com/UI/Datepicker/formatDate) (see http://www.php.net/date)
  *  * date:      Options for the date widget (see sfWidgetFormDate)
  *  * hours:     Options for the hours widget (see sfWidgetFormChoice)
  *  * minutes:   Options for the minutes widget (see sfWidgetFormChoice)
  *  * period:    Options for the period widget (see sfWidgetFormChoice)
  *  * format:    The format string for the datetime widget (default to %date% %hours% %minutes% %period%)
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('format_date', array('js' => 'ISO_8601', 'php' => 'Y-m-d H:i:s'));
     $this->addOption('date', array());
     $this->addOption('hours', array('choices' => parent::generateTwoCharsRange(1, 12)));
     $this->addOption('minutes', array('choices' => parent::generateTwoCharsRange(0, 59)));
     $this->addOption('period', array('choices' => array('AM' => 'AM', 'noon' => 'Noon', 'PM' => 'PM', 'midnight' => 'Midnight')));
     $this->addOption('format', '%date% %hours% %minutes% %period%');
 }
开发者ID:yasirgit,项目名称:afids,代码行数:30,代码来源:widgetFormDateTimeCustom.class.php

示例3: configure

 /**
  * Configures the current widget.
  *
  * Available options:
  *
  *  * format:       The date format string (%month%/%day%/%year% by default)
  *  * years:        An array of years for the year select tag (optional)
  *  * months:       An array of months for the month select tag (optional)
  *  * days:         An array of days for the day select tag (optional)
  *  * can_be_empty: Whether the widget accept an empty value (true by default)
  *  * empty_values: An array of values to use for the empty value (empty string for year, month, and date by default)
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('format', '%month%/%day%/%year%');
     $this->addOption('days', parent::generateTwoCharsRange(1, 31));
     $this->addOption('months', parent::generateTwoCharsRange(1, 12));
     $years = range(date('Y') - 5, date('Y') + 5);
     $this->addOption('years', array_combine($years, $years));
     $this->addOption('can_be_empty', true);
     $this->addOption('empty_values', array('year' => '', 'month' => '', 'day' => ''));
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:27,代码来源:sfWidgetFormDate.class.php

示例4: configure

 /**
  * Constructor.
  *
  * Available options:
  *
  *  * format:                 The time format string (%hour%:%minute%:%second%)
  *  * format_without_seconds: The time format string without seconds (%hour%:%minute%)
  *  * with_seconds:           Whether to include a select for seconds (false by default)
  *  * hours:                  An array of hours for the hour select tag (optional)
  *  * minutes:                An array of minutes for the minute select tag (optional)
  *  * seconds:                An array of seconds for the second select tag (optional)
  *  * can_be_empty:           Whether the widget accept an empty value (true by default)
  *  * empty_values:           An array of values to use for the empty value (empty string for hours, minutes, and seconds by default)
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('format', '%hour%:%minute%:%second%');
     $this->addOption('format_without_seconds', '%hour%:%minute%');
     $this->addOption('with_seconds', false);
     $this->addOption('hours', parent::generateTwoCharsRange(0, 23));
     $this->addOption('minutes', parent::generateTwoCharsRange(0, 59));
     $this->addOption('seconds', parent::generateTwoCharsRange(0, 59));
     $this->addOption('can_be_empty', true);
     $this->addOption('empty_values', array('hour' => '', 'minute' => '', 'second' => ''));
 }
开发者ID:sensorsix,项目名称:app,代码行数:30,代码来源:sfWidgetFormTime.class.php

示例5: configure

 /**
  * Constructor.
  *
  * Available options:
  *
  *  * format:                 The time format string (%hour%:%minute%:%second%)
  *  * format_without_seconds: The time format string without seconds (%hour%:%minute%)
  *  * with_seconds:           Whether to include a select for seconds (false by default)
  *  * hours:                  An array of hours for the hour select tag (optional)
  *  * minutes:                An array of minutes for the minute select tag (optional)
  *  * seconds:                An array of seconds for the second select tag (optional)
  *  * can_be_empty:           Whether the widget accept an empty value (true by default)
  *  * empty_values:           An array of values to use for the empty value (empty string for hours, minutes, and seconds by default)
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetForm
  */
 protected function configure($options = array(), $attributes = array())
 {
     $with_meridiem = isset($options['with_meridiem']) && $options['with_meridiem'];
     $this->addOption('format', '%hour%:%minute%:%second%' . ($with_meridiem ? ' %meridiem%' : ''));
     $this->addOption('format_without_seconds', '%hour%:%minute%' . ($with_meridiem ? ' %meridiem%' : ''));
     $this->addOption('with_seconds', false);
     $this->addOption('with_meridiem', false);
     $this->addOption('hours', $with_meridiem ? parent::generateTwoCharsRange(1, 12) : parent::generateTwoCharsRange(0, 23));
     $this->addOption('minutes', parent::generateTwoCharsRange(0, 59));
     $this->addOption('seconds', parent::generateTwoCharsRange(0, 59));
     $this->addOption('meridiem', array('am' => 'AM', 'pm' => 'PM'));
     $this->addOption('can_be_empty', true);
     $this->addOption('empty_values', array('hour' => '', 'minute' => '', 'second' => '', 'meridiem' => ''));
 }
开发者ID:bshaffer,项目名称:Symfony-Snippets,代码行数:33,代码来源:csWidgetFormTime.class.php

示例6: configure

 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('days', parent::generateTwoCharsRange(1, 31));
     $this->addOption('months', parent::generateTwoCharsRange(1, 12));
     $years = range(date('Y') - 5, date('Y') + 5);
     $this->addOption('years', array_combine($years, $years));
     $this->addOption('can_be_empty', true);
     $this->addOption('empty_value', '');
     $this->addRequiredOption('culture');
     $this->addOption('use', 'months');
     $this->addOption('format');
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $format = isset($options['format']) ? $options['format'] : 'name';
     $this->setOption('months', $this->getMonthFormat($culture, $format));
     $this->setOption('days', $this->getDayFormat($culture, $format));
 }
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:16,代码来源:sfWidgetFormI18nDateDMY.class.php

示例7: render

 /**
  * @param  string $name        The element name
  * @param  string $value       The time displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $use_period = $this->getOption('period') == true;
     if (!$use_period) {
         $this->setOption('hours', parent::generateTwoCharsRange(0, 23));
     }
     // convert value to an array
     $default = array('hour' => null, 'minute' => null, 'second' => null, 'period' => null);
     if (is_array($value)) {
         $value = array_merge($default, $value);
     } else {
         $value = ctype_digit($value) ? (int) $value : strtotime($value);
         if (false === $value) {
             $value = $default;
         } else {
             // int cast required to get rid of leading zeros
             $value = array('hour' => (int) date('H', $value), 'minute' => (int) date('i', $value), 'second' => (int) date('s', $value), 'period' => date('A', $value));
         }
     }
     $time = array();
     $emptyValues = $this->getOption('empty_values');
     // hours
     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['hour']) + $this->getOption('hours') : $this->getOption('hours')), array_merge($this->attributes, $attributes));
     $time['%hour%'] = $widget->render($name . '[hour]', $value['hour']);
     // minutes
     $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['minute']) + $this->getOption('minutes') : $this->getOption('minutes')), array_merge($this->attributes, $attributes));
     $time['%minute%'] = $widget->render($name . '[minute]', $value['minute']);
     if ($this->getOption('with_seconds')) {
         // seconds
         $widget = new sfWidgetFormSelect(array('choices' => $this->getOption('can_be_empty') ? array('' => $emptyValues['second']) + $this->getOption('seconds') : $this->getOption('seconds')), array_merge($this->attributes, $attributes));
         $time['%second%'] = $widget->render($name . '[second]', $value['second']);
     }
     if ($use_period) {
         // period (AM/PM)
         $widget = new sfWidgetFormSelect(array('choices' => array('AM' => 'AM', 'PM' => 'PM')), array_merge($this->attributes, $attributes));
         $time['%period%'] = $widget->render($name . '[period]', $value['period']);
     } else {
         $time['%period%'] = '';
     }
     return strtr($this->getOption('with_seconds') ? $this->getOption('format') : $this->getOption('format_without_seconds'), $time);
 }
开发者ID:yasirgit,项目名称:afids,代码行数:51,代码来源:widgetFormTime.class.php


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