Development

/branches/1.2/lib/widget/i18n/sfWidgetFormI18nDateTime.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/widget/i18n/sfWidgetFormI18nDateTime.class.php

Revision 9173, 1.8 kB (checked in by dwhittle, 6 years ago)

1.1: fixed attributes in date time widgets (closes #3601)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfWidgetFormI18nDateTime represents a date and time widget.
13  *
14  * @package    symfony
15  * @subpackage widget
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfWidgetFormI18nDateTime extends sfWidgetFormDateTime
20 {
21   /**
22    * Constructor.
23    *
24    * Available options:
25    *
26    *  * culture: The culture to use for internationalized strings (required)
27    *
28    * @param array $options     An array of options
29    * @param array $attributes  An array of default HTML attributes
30    *
31    * @see sfWidgetFormDateTime
32    */
33   protected function configure($options = array(), $attributes = array())
34   {
35     parent::configure($options, $attributes);
36
37     $this->addRequiredOption('culture');
38
39     $culture = isset($options['culture']) ? $options['culture'] : 'en';
40
41     // format
42     $this->setOption('format', str_replace(array('{0}', '{1}'), array('%time%', '%date%'), sfDateTimeFormatInfo::getInstance($culture)->getDateTimeOrderPattern()));
43   }
44
45   /**
46    * @see sfWidgetFormDateTime
47    */
48   protected function getDateWidget($attributes = array())
49   {
50     return new sfWidgetFormI18nDate(array_merge(array('culture' => $this->getOption('culture')), $this->getOptionsFor('date')), $this->getAttributesFor('date', $attributes));
51   }
52
53   /**
54    * @see sfWidgetFormDateTime
55    */
56   protected function getTimeWidget($attributes = array())
57   {
58     return new sfWidgetFormI18nTime(array_merge(array('culture' => $this->getOption('culture')), $this->getOptionsFor('time')), $this->getAttributesFor('time', $attributes));
59   }
60 }
61
Note: See TracBrowser for help on using the browser.