1. sfWidgetFormI18nChoiceTimezone.class.php
  2. /** * sfWidgetFormI18nChoiceTimezone represents a timezone choice widget. * * @package symfony * @subpackage widget * @author Fabien Potencier * @version SVN: $Id: sfWidgetFormI18nChoiceTimezone.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ */
  3. class sfWidgetFormI18nChoiceTimezone extends sfWidgetFormChoice
  4. {
  5. /**
  6. * Constructor.
  7. *
  8. * Available options:
  9. *
  10. * * culture: The culture to use for internationalized strings
  11. * * add_empty: Whether to add a first empty value or not (false by default)
  12. * If the option is not a Boolean, the value will be used as the text value
  13. *
  14. * @param array $options An array of options
  15. * @param array $attributes An array of default HTML attributes
  16. *
  17. * @see sfWidgetFormChoice
  18. */
  19. protected function configure($options = array(), $attributes = array())
  20. {
  21. parent::configure($options, $attributes);
  22. $this->addOption('culture');
  23. $this->addOption('add_empty', false);
  24. $culture = isset($options['culture']) ? $options['culture'] : 'en';
  25. $timezones = array_keys(sfCultureInfo::getInstance($culture)->getTimeZones());
  26. $timezones = array_combine($timezones, $timezones);
  27. $addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
  28. if (false !== $addEmpty)
  29. {
  30. $timezones = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $timezones);
  31. }
  32. $this->setOption('choices', $timezones);
  33. }
  34. }

Debug toolbar